Advertisement
Mr_D3a1h

Structure

Mar 13th, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. using namespace std;
  2. struct transport{
  3.     char Name[32];
  4.     char LastName[32];
  5.     char MiddleName[32];
  6.     int Baggage;
  7.     int Mass;
  8.     int summbag[10];
  9.    
  10. };
  11. int main()
  12. {
  13.     int kolvo,count = 0,count2 = 0;
  14.     cout << "Введите кол-во пассажиров: ";
  15.     cin >> kolvo;
  16.    
  17.     transport People[kolvo];
  18.    
  19.     for(int i = 0; i < kolvo; i++)
  20.     {
  21.         cout << "Фамилия: ";
  22.         cin >> People[i].LastName;
  23.         cout << "Имя: ";
  24.         cin >> People[i].Name;
  25.         cout << "Отчество: ";
  26.         cin >> People[i].LastName;
  27.         cout << "Количество Багажа: ";
  28.         cin >> People[i].Baggage;
  29.         for (int j = 0; j < People[i].Baggage; j++)
  30.         {
  31.            
  32.             cout << "Масса Багажа " << j + 1<< ": ";
  33.             cin >> People[i].Mass;
  34.             People[i].summbag[j] += People[i].Mass;
  35.         }
  36.        
  37.         cin.get();
  38.         cout << endl;
  39.     }
  40.     for(int i = 0; i < kolvo; i++)
  41.     {
  42.         for(int j = 0; j < People[i].Baggage; j ++)
  43.         {
  44.             count += People[i].summbag[j];
  45.             if((j == People[i].Baggage -1 ) and count > 30)
  46.             {
  47.                 count2 ++;
  48.             }
  49.            
  50.         }
  51.         count = 0;
  52.     }
  53.     cout << "Кол-во Пассажиров с багажом более 30 кг = " << count2 << endl;
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement