Quipex

laba_7.3

Nov 25th, 2015
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.15 KB | None | 0 0
  1. // Laba_7.3.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include<iostream>
  6. #include "windows.h"
  7. using namespace std;
  8.  
  9.  
  10. int _tmain(int argc, _TCHAR* argv[])
  11. {
  12.     setlocale(0,"rus");
  13.     struct strc
  14.     {
  15.         int Number;
  16.         char TypeOfPlane[20];
  17.         char Destination[20];
  18.         int HoursDepart;
  19.         int MinutesDepart;
  20.     }Flight[100];
  21.    
  22.     //input
  23.     cout<<"Введите кол-во рейсов на завтра \n>> ";
  24.     int k,i,j;
  25.     cin>>k;
  26.     char semicolon[1];
  27.     for(i=0;i<k;i++)
  28.     {
  29.         cout<<"i="<<i<<endl;
  30.         cout<<"\n\n+-------------------------------------~\n";
  31.         cout<<"| Номер рейса           :  "; cin>>Flight[i].Number;
  32.         cout<<"| Тип самолёта          :  "; cin>>Flight[i].TypeOfPlane;
  33.         cout<<"| Пункт Назначения      :  "; cin>>Flight[i].Destination;
  34.         cout<<"| Время Вылета (часы)   :  "; cin>>Flight[i].HoursDepart;
  35.         cout<<"| Время Вылета (минуты) :  "; cin>>Flight[i].MinutesDepart;
  36.         cout<<"+-------------------------------------~\n";
  37.     }
  38.  
  39.     //sotring
  40.     strc sTemp;
  41.     for(i=0;i<k-1;i++)
  42.     {
  43.         for(j=i;j<k;j++)
  44.         {
  45.             if((Flight[j].HoursDepart<Flight[i].HoursDepart)
  46.             ||((Flight[j].HoursDepart==Flight[i].HoursDepart)&&(Flight[i].MinutesDepart>Flight[j].MinutesDepart)))
  47.             {
  48.                 {
  49.                     sTemp=Flight[i];
  50.                     Flight[i]=Flight[j];
  51.                     Flight[j]=sTemp;
  52.                 }
  53.             }
  54.         }
  55.     }
  56.  
  57.     //asking for a destination
  58.     cout<<"\n\nВведите пункт назначения\n>>";
  59.     char dest[20];
  60.     cin>>dest;
  61.  
  62.     //output
  63.     for(i=0;i<k;i++)
  64.     {
  65.         if(strcmp(dest,Flight[i].Destination)==0)
  66.         {
  67.             cout<<"i="<<i<<endl;
  68.             cout<<"\n\n+-------------------------------------~\n";
  69.             cout<<"| Номер рейса           :  "<<Flight[i].Number<<endl;
  70.             cout<<"| Тип самолёта          :  "<<Flight[i].TypeOfPlane<<endl;
  71.             cout<<"| Пункт Назначения      :  "<<Flight[i].Destination<<endl;
  72.             cout<<"| Время Вылета (чч)     :  "<<Flight[i].HoursDepart<<endl;
  73.             cout<<"| Время Вылета (мм)     :  "<<Flight[i].MinutesDepart<<endl;
  74.             cout<<"+-------------------------------------~\n";
  75.         }
  76.     }
  77.     return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment