Structure
Please, help! How can I add to this code else cout<<"Impossible"; #include<bits/stdc++.h> using namespace std; struct train{ int id; char* adr; char* time; }; int main(){ int n; cin>>n; train*a=new train[n]; for(int i=0;i<n;++i){ a[i].adr=new char[100]; a[i].time=new char[5]; cin>>a[i].id>>a[i].adr>>a[i].time; for(int j=0;j<n;++j){ a[i].adr[j]=toupper(a[i].adr[j]); } } string dest; cin>>dest; int mt=99999; int index=-1; for(int i=0;i<dest.length();++i) dest[i]=toupper(dest[i]); for(int i=0;i<n;++i) { if(dest==a[i].adr){ int time=((a[i].time[0]-'0')*10+(a[i].time[1]-'0'))*60+((a[i].time[3]-'0')*10+(a[i].time[4]-'0')); if(mt>time) { mt=time; index=i; } } } cout<<"\n"<<a[index].id<<" "<<a[index].adr<<" "<<a[index].time; return 0; }