Yangyylj 提交的代码
提交时间:2021 五月 语言:C++运行时间:344ms占用内存:410K
运行状态: Accepted
题目:日志排序1227

登录之后查看代码,点此登录账号

                
                    #include<bits/stdc++.h>
using namespace std;

struct task {
	string id;
	string day;
	string mytime;
	string cost;
}t[10010];

bool cmp(task a, task b) {
	if (a.cost == b.cost) {
		if (a.day == b.day) {
			return a.mytime < b.mytime;
		}
		else {
			return a.day < b.day;
		}
	}
	return a.cost < b.cost;
}
int main()
{
	string b, d, k, c;
	int num = 0;
	while (cin >> b >> d >> k >> c) {
		t[num].id = b;
		t[num].day = d;
		t[num].mytime = k;
		t[num].cost = c;
		num++;
	}
	sort(t, t + num, cmp);
	for (int i = 0; i < num; i++) {
		cout << t[i].id << "   " << t[i].day << " " << t[i].mytime;
		cout << setfill(' ')<< setw(15) << t[i].cost << endl;
	}
}