//参考题解给的iostream便于处理字符串 #include <iostream> #include<string> #include<algorithm> #include<sstream> using namespace std; struct record { string name; string startDay; string startTime; double costTime; string line; }; bool cmp(record r1,record r2) { if(r1.costTime!=r2.costTime)return r1.costTime<r2.costTime; else { if(r1.startDay!=r2.startDay)return r1.startDay<r2.startDay; else return r1.startTime<r2.startTime; } } int main() { record r[10000]; int i=0; string s; while (getline(cin,s)) { r[i].line=s; istringstream lineStream(s); lineStream >>r[i].name>>r[i].startDay>>r[i].startTime>>r[i].costTime; //cout<<r[i].line<<endl; /* cout<<"i="<<i<<endl; cout<<r[i].name<<" "<<r[i].startDay<<" "<<r[i].startTime <<" "<<r[i].costTime<<endl; */ i++; } sort(r,r+i,cmp); for(int j=0;j<i;j++) { cout<<r[j].line<<endl; /* cout<<"test"<<endl; cout<<r[i].name<<" "<<r[i].startDay<<" "<<r[i].startTime <<" "<<r[i].costTime<<endl; */ } } // 64 位输出请用 printf("%lld")