远离这道题,会变得不幸
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
using namespace std;
struct People{
//题给的结构体,注意该结构体不能修改,避免文件读取错误
char id[19]; /* 身份证号码 */
int social; /* 社保缴纳月数 */
int area; /* 现有住房面积 */
char date[11]; /* 申报日期 */
};
struct people{
//魔改的结构体
string id; /* 身份证号码 */
int social; /* 社保缴纳月数 */
int area; /* 现有住房面积 */
string date; /* 申报日期 */
int dateint=0;//日期拼接成的整数
int rank=0;//排名
int samerank=0;//并列排名的人数
};
vector<string> split(string s,string separate){
//字符串分段函数
vector<string> splited;
unsigned int separate_len=separate.length();
unsigned int start=0;
int index;
while((index=s.find(separate,start))!=-1){
splited.push_back(s.substr(start,index-start));
start=index+separate_len;
}
if(start<s.length()){
splited.push_back(s.substr(start,s.length()-start));
}
return splited;
}
bool compare1(people data1,people data2){
//刚性需求自定义排序
if (data1.social==data2.social){
return data1.dateint < data2.dateint;
}
else{
return data1.social>data2.social;
}
}
bool compare2(people data1,people data2){
//改善性需求自定义排序
if (data1.area==data2.area){
return data1.dateint < data2.dateint;
}
else{
return data1.area<data2.area;
}
}
People* getMess(int &n){
//题给的读文件函数
FILE* fp;
fp=fopen("house.bin","rb");
fseek(fp,-1*(long)sizeof(int), 2);
fread(&n, sizeof(int),1, fp);
rewind(fp);
People