Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Laba_7.3.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include<iostream>
- #include "windows.h"
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- setlocale(0,"rus");
- struct strc
- {
- int Number;
- char TypeOfPlane[20];
- char Destination[20];
- int HoursDepart;
- int MinutesDepart;
- }Flight[100];
- //input
- cout<<"Введите кол-во рейсов на завтра \n>> ";
- int k,i,j;
- cin>>k;
- char semicolon[1];
- for(i=0;i<k;i++)
- {
- cout<<"i="<<i<<endl;
- cout<<"\n\n+-------------------------------------~\n";
- cout<<"| Номер рейса : "; cin>>Flight[i].Number;
- cout<<"| Тип самолёта : "; cin>>Flight[i].TypeOfPlane;
- cout<<"| Пункт Назначения : "; cin>>Flight[i].Destination;
- cout<<"| Время Вылета (часы) : "; cin>>Flight[i].HoursDepart;
- cout<<"| Время Вылета (минуты) : "; cin>>Flight[i].MinutesDepart;
- cout<<"+-------------------------------------~\n";
- }
- //sotring
- strc sTemp;
- for(i=0;i<k-1;i++)
- {
- for(j=i;j<k;j++)
- {
- if((Flight[j].HoursDepart<Flight[i].HoursDepart)
- ||((Flight[j].HoursDepart==Flight[i].HoursDepart)&&(Flight[i].MinutesDepart>Flight[j].MinutesDepart)))
- {
- {
- sTemp=Flight[i];
- Flight[i]=Flight[j];
- Flight[j]=sTemp;
- }
- }
- }
- }
- //asking for a destination
- cout<<"\n\nВведите пункт назначения\n>>";
- char dest[20];
- cin>>dest;
- //output
- for(i=0;i<k;i++)
- {
- if(strcmp(dest,Flight[i].Destination)==0)
- {
- cout<<"i="<<i<<endl;
- cout<<"\n\n+-------------------------------------~\n";
- cout<<"| Номер рейса : "<<Flight[i].Number<<endl;
- cout<<"| Тип самолёта : "<<Flight[i].TypeOfPlane<<endl;
- cout<<"| Пункт Назначения : "<<Flight[i].Destination<<endl;
- cout<<"| Время Вылета (чч) : "<<Flight[i].HoursDepart<<endl;
- cout<<"| Время Вылета (мм) : "<<Flight[i].MinutesDepart<<endl;
- cout<<"+-------------------------------------~\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment