1006 Sign In and Sign Out (25point(s)) Easy only once *cmp sort排序问题
基本思想: 1.使用类输入,构造成一个序列; 2.直接两次排序; 关键点: 注意sort和cmp的返回值和构造问题; 1 #include<iostream> 2 #include<stdlib.h> 3 #include<stdio.h> 4 #include<vector> 5 #include<string> 6 #include<math.h> 7 #include<algorithm> 8 using namespace std; 9 using std::vector; 10 struct student{ 11 char id[16]; 12 int sh; 13 int sm; 14 int ss; 15 int eh; 16 int em; 17 int es; 18 }; 19 vector<student>vec; 20 bool flag = false; 21 bool cmp(student a, student b) { 22 if (flag) { 23 if (a.sh != b.sh) 24 return a.sh > b.sh; 25 else if (a.sm != b.sm) 26 return a.sm > b.sm; 27 else 28 return a.ss > b.ss; 29 } 30 else { 31 if (a.eh !=