Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <iostream>
- # include <cstring>
- #include <cctype>
- using namespace std;
- struct train
- {
- char item[15];
- int number;
- char time[6];
- };
- int main()
- {
- train inf[100];
- int j, n, i;
- char nom[15];
- bool flag=false;
- cin >> n;
- if(n >= 1 && n <= 1001)
- {for(j=0; j < n; j++)
- {cin>>inf[j].number >> inf[j].item >> inf[j].time;
- for(int i = 0; i<strlen(inf[j].item); i++)
- { inf[j].item[i] = (char)toupper(inf[j].item[i]);}}}
- for(j = 0; j < n; j++)
- {int x = n-1; do
- {if(stricmp(inf[x].item, inf[x-1].item)==0)
- { return 0; }
- x--;}
- while (x > 0);
- }
- cin>>nom;
- for (i=0; i<n; i++){
- if (stricmp(nom, inf[i].item)==0)
- { flag = true;
- cout << inf[i].number <<"_"<< inf[i].item <<"_"<< inf[i].time;}
- }
- if (flag==false)
- {
- cout<<"Impossible";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement