Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # include <iostream>
  2. # include <cstring>
  3. #include <cctype>
  4. using namespace std;
  5. struct train
  6. {
  7.     char item[15];
  8.     int number;
  9.     char time[6];
  10. };
  11. int main()
  12. {
  13.     train inf[100];
  14.     int j, n, i;
  15.     char nom[15];
  16.     bool flag=false;
  17.     cin >> n;
  18.     if(n >= 1 && n <= 1001)
  19. {for(j=0; j < n; j++)
  20. {cin>>inf[j].number >> inf[j].item >> inf[j].time;
  21. for(int i = 0; i<strlen(inf[j].item); i++)
  22. { inf[j].item[i] = (char)toupper(inf[j].item[i]);}}}
  23.     for(j = 0; j < n; j++)
  24.     {int x = n-1; do
  25. {if(stricmp(inf[x].item, inf[x-1].item)==0)
  26. { return 0; }
  27. x--;}
  28. while (x > 0);
  29.     }
  30.     cin>>nom;
  31.     for (i=0; i<n; i++){
  32. if (stricmp(nom, inf[i].item)==0)
  33. { flag = true;
  34. cout << inf[i].number <<"_"<< inf[i].item <<"_"<< inf[i].time;}
  35. }
  36.     if (flag==false)
  37.     {
  38.         cout<<"Impossible";
  39.     }
  40.     return 0;
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement