h〉
#include〈string。
h>
structstudent
{
charnum[10];
charname[10];
charsex[4];
charclas[20];
intyw,sx,yy;
floatave;
}stu[100];
inti,j;
voidInputData()
{
charx;
while
(1)
{
printf(”\t学号:
”);
scanf(”%s",stu[i]。
num);
printf(”\t姓名:
”);
scanf(”%s",stu[i].name);
printf("\t性别:
");
scanf("%s”,stu[i]。
sex);
printf("\t班级:
”);
scanf(”%s",stu[i].clas);
printf("\t语文:
”);
scanf(”%d",&stu[i]。
yw);
printf("\t数学:
”);
scanf("%d",&stu[i]。
sx);
printf(”\t英语:
");
scanf(”%d”,&stu[i].yy);
stu[i]。
ave=float((stu[i].yw+stu[i]。
sx+stu[i].yy)/3。
0);
i++;
printf(”\t是否继续输入数据(Y。
N)");cin>〉x;
if(x==’n'||x==’N’)break;
}
}
voidEditData()
{
intcount=0;
charstr[10];
printf(”\n请输入学生学号:
");
cin>〉str;
while(count〈i)
{
if(strcmp(str,stu[count].num)==0)
{
printf("学号姓名性别班级语文数学英语\n”);
printf("-——--—----—---—-—————--—-———--——--———--———-------—-——-——-———--——\n");
printf("%-11s",stu[count]。
num);
printf(”%—13s”,stu[count]。
name);
printf(”%—8s",stu[count].sex);
printf(”%-16s",stu[count]。
clas);
printf("%-6d",stu[count].yw);
printf(”%—6d”,stu[count]。
sx);
printf("%—4d”,stu[count].yy);
printf(”\n”);
printf(”-—-——————-—--——-—-—--—----————--—---——-———---——----——————--—-———\n");
break;
}
count++;
}
if(count>=i)
printf(”\n查无此人”);
else
{
printf("\n\t修改数据:
\n”);
printf("\t学号:
”);
scanf(”%s",stu[i]。
num);
printf("\t姓名:
”);
scanf(”%s",stu[i]。
name);
printf("\t性别:
");
scanf(”%s”,stu[i]。
sex);
printf("\t班级:
”);
scanf("%s",stu[i].clas);
printf(”\t语文:
");
scanf("%d”,&stu[i].yw);
printf("\t数学:
”);
scanf(”%d",&stu[i]。
sx);
printf(”\t英语:
");
scanf("%d”,&stu[i]。
yy);
stu[count]。
ave=float((stu[count]。
yw+stu[count].sx+stu[count].yy)/3。
0);
}
}
voidsx()
{
structstudenttemp;
inta,b,c;
for(a=0;a
{
c=a;
for(b=a+1;b〈i;b++)
if(stu[b]。
ave>stu[c]。
ave)
c=b;
temp=stu[b];
stu[b]=stu[c];
stu[c]=temp;
}
printf("排序后结果为:
\n”);
printf(”学号姓名性别班级语文数学英语\n");
printf(”——-—-—-—---———-————-————---—--——--——----———--———-—--—---——-—-——-\n”);
for(c=0;c〈i;c++)
{
printf(”%—11s”,stu[c].num);
printf(”%-13s”,stu[c]。
name);
printf("%-8s",stu[c].sex);
printf("%—16s",stu[c]。
clas);
printf(”%-6d”,stu[c]。
yw);
printf("%—6d",stu[c].sx);
printf("%-4d”,stu[c].yy);
printf("\n");
}
printf("-——-—--——--—----—-—-—-——-———--—-—-——---————--———--———-—-—--—-—--\n”);
}
voidcx()
{
intcount=0;
charstr[10];
printf("\n请输入要查询的学生学号:
”);
cin〉〉str;
while(count
{
if(strcmp(str,stu[count].num)==0)
{
printf("学号姓名性别班级语文数学英语\n”);
printf("—----—-—-——-—-——-—---—--—-----—--——--—-—-——-———-———----——----—--\n”);
printf(”%-11s",stu[count]。
num);
printf(”%-13s”,stu[count].name);
printf("%—8s",stu[count]。
sex);
printf("%—16s",stu[count].clas);
printf("%-6d”,stu[count].yw);
printf("%-6d”,stu[count]。
sx);
printf(”%—4d",stu[count]。
yy);
printf(”\n”);
printf(”——-——-——-----—-———————--————---—-——--—---——---—-——--—-—--——--———\n”);
break;
}
count++;
}
if(count〉=i)
printf(”\n无该学号学生”);
else
{
printf("\n");
}
}
voidtjpjf()
{
intcount=0;
stu[i]。
ave=float((stu[i].yw+stu[i]。
sx+stu[i]。
yy)/3。
0);
printf("学号姓名平均分\n”);
printf("—----—-—--—--—--—-----——---——----——-——--—----—-—--\n");
for(j=0;j
while(count
{
for(j=0;j
{
printf("%—21s”,stu[count].num);
printf(”%-21s",stu[count]。
name);
printf("%—6.2f",stu[count].ave);
count++;
printf(”\n");}
}
printf("——--—--——--—-—--—-—----——-———---—-—-———-——-----—--\n");
}
voidtjbhgrs()
{
intj,count=0;
printf("有不及格科目的学生是:
\n”);
printf(”学号姓名性别班级语文数学英语\n”);
printf("——--——---———-——---———-----—-—--——--------—--—--—--—-————-——-————\n");
for(j=0;j
{
if(stu[j].yw<60||stu[j].sx<60||stu[j]。
yy〈60)
{printf("%-11s",stu[count].num);
printf(”%-13s”,stu[count]。
name);
printf(”%—8s”,stu[count].sex);
printf(”%—16s”,stu[count]。
clas);
printf(”%-6d”,stu[count].yw);
printf(”%-6d”,stu[count].sx);
printf(”%—4d",stu[count].yy);
printf(”\n");
}
count++;
}
printf(”——-—-————-----—————---——---————————-——--—--—-—-—-——-—-—————-----\n”);
}
voidtj()
{
charx;
while
(1)
{
printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n”);
printf(”\t1.统计平均分2。
统计不及格学生信息3。
返回\n”);
printf("\t~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n”);
printf("\n\t请选择具体的统计内容:
");
cin>〉x;
printf("\n");
switch(x)
{
case'1':
tjpjf();break;
case'2':
tjbhgrs();bre