Advertisement
cacodemon665

Лаба 7 Вариант 13

Dec 11th, 2018
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.07 KB | None | 0 0
  1. #include "pch.h" //для версий вижлы старше последних версий 2017 здесь должно быть #include "stdafx.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. struct TrainData
  7. {
  8.     int day;
  9.     int destination;
  10.     int time;
  11.     int tickets;
  12. };
  13.  
  14.  
  15. int main()
  16. {
  17.     int n;
  18.     cout << "Enter number of trains:";
  19.     cin >> n;
  20.  
  21.     TrainData data[1000];
  22.  
  23.     for (int i = 0; i < n; i++)
  24.     {
  25.         cout << i + 1 << endl;
  26.  
  27.         cin.ignore(1, '\n');
  28.  
  29.         cout << "Enter destination: ";
  30.         cin >> data[i].destination;
  31.         cout << "Enter day: ";
  32.         cin >> data[i].day;
  33.         cout << "Enter time: ";
  34.         cin >> data[i].time; // тут время вводится в 24 часовом формате
  35.         cout << "Enter tickets: ";
  36.         cin >> data[i].tickets;
  37.     }
  38.  
  39.     int m, N, k, t;
  40.     cout << "m, N, k, t(pm): ";// а тут pm
  41.     cin >> m >> N >> k >> t;
  42.     t += 12;
  43.  
  44.     for (int i = 0; i < n; i++)
  45.     {
  46.         if (data[i].destination == N && data[i].tickets >= m && data[i].day == k && data[i].time <= t)
  47.         {
  48.             cout << t;
  49.             return 0;
  50.         }
  51.     }
  52.  
  53.     cout << "imposible";
  54.  
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement