You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
2.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include"c1.cpp"
void section() //学生成绩分段
{
system("cls");
int k=0;
double c;
if((fp=fopen("a.txt","r"))==NULL)
{
printf("Cannot open the file!\n");
}
while(fscanf(fp,"%lf%s%f",&s[k].no,s[k].name,&s[k].cscore)!=EOF)
{
k++;
}
printf("\t\t\t 90分以上学生的信息!\n");
for(i=0;i<k;i++)
if(s[i].cscore>=90)
printf("\t\t\t%.0lf %s %.1f\n",s[i].no,s[i].name,s[i].cscore);
printf("\n\n");
printf("\t\t\t 80到89分学生的信息!\n");
for(i=0;i<k;i++)
if(s[i].cscore<90&&s[i].cscore>=80)
printf("\t\t\t%.0lf %s %.1f\n",s[i].no,s[i].name,s[i].cscore);
printf("\n\n");
printf("\t\t\t 60到79分学生的信息!\n");
for(i=0;i<k;i++)
if(s[i].cscore>=60&&s[i].cscore<80)
printf("\t\t\t%.0lf %s %.1f\n",s[i].no,s[i].name,s[i].cscore);
printf("\n\n");
printf("\t\t\t 60分以下学生的信息!\n");
for(i=0;i<k;i++)
if(s[i].cscore<60)
printf("\t\t\t%.0lf %s %.1f\n",s[i].no,s[i].name,s[i].cscore);
printf("\n\n");
}
void rank() //成绩的排序
{
Student t;
int k=0;
double sum=0,j=0;
system("cls");
if((fp=fopen("a.txt","r"))==NULL)
{
printf("Cannot open the file!\n");
}
while(fscanf(fp,"%lf%s%f",&s[k].no,s[k].name,&s[k].cscore)!=EOF)
{
k++;
}
for(i=0;i<k;i++)
for(int j=i+1;j<k+1;j++)
if(s[i].cscore<s[j].cscore)
{t=s[i];s[i]=s[j];s[j]=t;}
for(i=0;i<k;i++)
{
if(s[i].cscore>=60)
j++;
}
for(i=0;i<k;i++)
sum=sum+s[i].cscore;
for(i=0;i<k;i++)
printf("\t\t\t第%d名:%.0lf %-4s %.1f\n",i+1,s[i].no,s[i].name,s[i].cscore);
printf("\t\t\t最高分:%.1lf\n",s[0].cscore);
printf("\t\t\t最低分:%.1lf\n",s[k-1].cscore);
printf("\t\t\t及格率:%.2lf\n",j/k);
printf("\t\t\t平均分:%.2lf\n",sum/k);
}
void choose(int n) //目录的选项
{
system("cls");
int y;
switch(n)
{
case 1:input();
printf("\n\n\n\n\t\t\t是否返回输入1表返回输入2表退出\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 2:output();
printf("\n\n\n\n\t\t\t是否返回输入1表返回输入2表退出\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 3:modify();
printf("\n\n\n\n\t\t\t是否返回输入1表返回输入2表退出\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 4:lookat();
printf("\n\n\n\n\t\t\t是否返回输入1表返回输入2表退出\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 5:section();
printf("\n\n\n\n\t\t\t是否返回输入1表返回输入2表退出\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 6:rank();
printf("\n\n\n\n\t\t\t是否返回输入1表返回输入2表退出\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 7:exit(0);break;
default:printf("\n\n\t\t\t 输入没有的选项,请重新输入!\n");
choose(fun());
}
}