資源簡介
大學課程設計,實現江蘇高考的錄取機制,有一個文件
代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
#include
using?namespace?std;
class?student
{
public:
char?name[20];
char?sex[20];
int?old;
char?examnum[20];
char?school[100];
int?num1;
int?chinese;
int?num2;
int?math;
int?num3;
int?english;
int?num4;
char?ctest1[20];
int?num5;
char?ctest2[20];
int?TP;?
};
int?cmp_ctest(const?char?a[]const?char?b[])
{
return?a[0] }
struct?Sorter
{
int?num4;
char?ctest1[20];
char?ctest2[20];
Sorter(int?tnum4char?*tctest1char?*tctest2)
{
num4=tnum4;
strcpy(ctest1tctest1);
strcpy(ctest2tctest2);
}
Sorter(int?tnum4const?char?*tctest1const?char?*tctest2)
{
num4=tnum4;
strcpy(ctest1tctest1);
strcpy(ctest2tctest2);
}
int?operator()(const?student?&xconst?student?&y)
{
if?(x.num4!=y.num4)
return?x.num4==num4;
if?(cmp_ctest(x.ctest1ctest1)!=cmp_ctest(y.ctest1ctest1))
return?cmp_ctest(x.ctest1ctest1);
if?(cmp_ctest(x.ctest2ctest2)!=cmp_ctest(y.ctest2ctest2))
return?cmp_ctest(x.ctest2ctest2);
if?(x.TP!=y.TP)
return?x.TP>y.TP;
if?(x.math!=y.math)
return?x.math>y.math;
if(x.chinese!=y.chinese)
return?x.chinese>y.chinese;
if(cmp_ctest(x.ctest1y.ctest1)!=1)
return?cmp_ctest(x.ctest1y.ctest1);
return?cmp_ctest(x.ctest2y.ctest2);
}
};
int?linenum(char?a[])
{
fstream?infile;
infile.open(aios::in);
if(!infile)
{
cout<<“不能打開輸入文件:“<<“data.txt“<<‘\n‘;
return?0;
}
char?str[256];
int?n=0;
while(!infile.eof())
{
infile.getline(str?255);
n++;
}
return?n;
infile.close();
}
void?Read(char?a[]ostream&outfilestudent?student[]int?n)
{
fstream?infile;
infile.open(aios::in);
if(!infile)
{
cout<<“不能打開輸入文件:“< exit(0);
}
for(int?x=0;x {
char?buff[256];
infile.getline(buff256‘‘);
strcpy(student[x].namebuff);
infile.getline(buff256‘‘);
strcpy(student[x].sexbuff);
infile.getline(buff256‘‘);
student[x].old=atol(buff);
infile.getline(buff256‘‘);
strcpy(student[x].examnumbuff);
infile.getline(buff256‘‘);
strcpy(student[x].schoolbuff);
infile.getline(buff256‘‘);
student[x].num1=atol(buff);
infile.getline(buff256‘‘);
student[x].chinese=atol(buff);
infile.getline(buff256‘‘);
student[x].num2=atol(buff);
infile.getline(buff256‘‘);
student[x].math=atol(buff);
infile.getline(buff256‘‘);
student[x].num3=atol(buff);
infile.getline(buff256‘‘);
student[x].english=atol(buff);
infile.getline(buff256‘‘);
student[x].num4=atol(buff);
infile.getline(buff256‘‘);
strcpy(student[x].ctest1buff);
infile.getline(buff256‘‘);
student[x].num5=atol(buff);
infile.getline(buff256);
strcpy(student[x].ctest2buff);
student[x].TP=student[x].chinese+student[x].math+s
- 上一篇:奔跑的火柴人
- 下一篇:PCM 8位文件提取PCM采樣的C語言代碼
評論
共有 條評論