计蒜客 第 m 大的身份证号码 (水)
链接 : Here!
**思路 : ** 水题
**代码 : **
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
struct info {
int ages;
string id;
};
int n, m;
bool cmp(info a, info b) {
if (a.ages == b.ages) {
return a.id < b.id;
}
return a.ages < b.ages;
}
int main() {
while (scanf("%d%d", &n, &m) != EOF) {
info data[110];
for (int i = 0 ; i < n ; ++i) {
cin >> data[i].id;
int temp = 0;
for (int j = 6 ; j <= 13 ; ++j) {
temp = temp * 10 + data[i].id[j];
}
data[i].ages = temp;
}
sort(data, data + n, cmp);
cout << data[m - 1].id << endl;
}
return 0;
}
如要转载请注明转载出处:http://www.cnblogs.com/WArobot