#include
#include
struct DATA
{
int ID;
char name[4];
char sex[3];
int score;
};
void paixu(int*,DATA*,int);
int sishewuru(double);
void func1(int*,int*,DATA*,int*,int,int,int,int);//统计男女比例
int func2(int*,int,DATA*);//查找考生序号
void print();
void main()
{
int length=0,i,yiben,erben,sanben,dazhuan,male[4],female[4];
int yi,er,san,si;
char input;
FILE* file=fopen("f1.txt","r"),*file1;
if(file==NULL)
{
printf("No such file!\n");
return;
}
while(EOF!=fscanf(file,"%*[^\n]\n")) length++;//自动计算考生数罝ATA* data=(DATA*)malloc(length*sizeof(DATA));
int* pai=(int*)malloc(length*sizeof(int));
rewind(file);
for(i=0;i='0'&&input<='4'))
{
printf("非法输入,请重新输入\n请输入:");
fflush(stdin);
}
else break;
}
getchar();
switch(input)
{
case '0':
printf("\n一类本科招生线:%d\n二类本科招生线:%d\三类本科招生线:%d\\n高职高专招生线:%d\n",yi,er,san,si);
printf("是否打印为文件?(y/n):");
if(getchar()=='y')
{
file1=fopen("各批次录取分数线.txt","w");
fprintf(file1,"一类本科招生线:%d\n二类本科招生线:%d\\n三类本科招生线:%d\n高职高专招生线:%d\n",yi,er,san,si);
fclose(file1);
}
fflush(stdin);
break;
case '1':
func1(male,female,data,pai,yiben,erben,sanben,dazhuan);
printf("一类本科招生线男女比例:%d:%d\n",male[0],female[0]);
printf("二类本科招生线男女比例:%d:%d\n",male[1],female[1]);
printf("三类本科招生线男女比例:%d:%d\n",male[2],female[2]);
printf("高职高专招生线招生线男女比例:%d:%d\n",male[3],female[3]);
printf("是否打印为文件?(y/n):");
if(getchar()=='y')
{
file1=fopen("各批次录取男女比例.txt","w");
fprintf(file1,"一类本科招生线男女比例:%d:%d\n",male[0],female[0]);