语言输入输出排序打印学生成绩单Word文档下载推荐.docx
- 文档编号:20337269
- 上传时间:2023-01-22
- 格式:DOCX
- 页数:15
- 大小:16.96KB
语言输入输出排序打印学生成绩单Word文档下载推荐.docx
《语言输入输出排序打印学生成绩单Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《语言输入输出排序打印学生成绩单Word文档下载推荐.docx(15页珍藏版)》请在冰豆网上搜索。
printf("
Inputstudentnumber(n<
30):
"
);
scanf("
%d"
&
n);
if(n>
N||n<
1)
return0;
else
//主程序
while(con!
=0)
{
//输出
printf("
\nManagementforStudents'
scores\n"
1.Appendrecord\n"
2.Calculatetotalandaveragescoreofeverycourse\n"
3.Calculatetotalandaveragescoreofeverystudent\n"
4.Sortindescendingorderbytotalscoreofeverystudent\n"
5.Sortinascendingorderbytotalscoreofeverystudent\n"
6.Sortinascendingorderbynumber\n"
7.Sortindictionaryorderbyname\n"
8.Searchbynumber\n"
9.Searchbyname\n"
10.Statisticanalysis\n"
11.Listrecord\n"
12.Writetoafile\n"
13.Readfromafile\n"
0.Exit\n"
//录入学生的人数:
PleaseInputyourchoice:
scanf("
con);
//录入每个学生的学号、姓名和各科成绩:
if(con==1)
{
printf("
Inputstudent'
sID,nameandscore:
\n"
for(i=0;
i<
n;
i++)
{
scanf("
%ld"
&
stu[i].id);
getchar();
fgets(stu[i].name,sizeof(stu[i].name),stdin);
///有问题!
!
%f%f%f"
stu[i].score[0],&
stu[i].score[1],&
stu[i].score[2]);
}
}
//计算每门课程的总分和平均分:
elseif(con==2)
addc(stu,n);
//计算每个学生各门课程的总分和平均分:
elseif(con==3)
adds(stu,n);
//按总成绩由高到低排出名次表:
elseif(con==4)
Sortindescendingorderbytotalscoreofeverystudent:
NO\tName\tMT\tEN\tPH\tSUM\tAVER\n"
pxs(stu,ds,n);
//按总成绩由低到高排出名次表:
elseif(con==5)
Sortinascendingorderbytotalscoreofeverystudent:
pxs(stu,as,n);
//按学号由小到大排出成绩表:
elseif(con==6)
Sortinascendingorderbynumber:
pxi(stu,n);
//按姓名的字典顺序排出成绩表:
elseif(con==7)
Sortindictionaryorderbyname:
pxn(stu,n);
//按学号查询学生排名、学号、姓名及其考试成绩:
elseif(con==8)
seai(stu,n);
//按姓名查询学生排名、学号、姓名及其考试成绩:
elseif(con==9)
sean(stu,n);
//按100,(90~100)(80~89)(70~79)(60~69)(0~59)统计各科每个类别的人数以及所占的百分比:
elseif(con==10)
ana(stu,n);
//输出信息
elseif(con==11)
for(i=0;
i<
n;
i++)
printf("
%ld\t"
stu[i].id);
for(j=0;
stu[i].name[j]!
='
\n'
;
j++)
{
putchar(stu[i].name[j]);
}
\t%.0f\t%.0f\t%.0f\t%.0f\t%.0f\n"
stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].score[3],(stu[i].score[3]/3));
//写入文件
elseif(con==12)
wri(stu,n);
//读取文件
elseif(con==13)
rea(stu,n);
elseif(con==0)
Endofprogram!
else
Inputerror!
}
}
return0;
}
voidaddc(structstudent*pt,intn)
inti,j;
floatsum;
for(j=0;
j<
3;
sum=0;
for(i=0;
sum+=stu[i].score[j];
printf("
course%d:
sum=%.0f,aver=%.0f\n"
(j+1),sum,(sum/n));
voidadds(structstudent*pt,intn)
inti;
for(i=0;
stu[i].score[3]=stu[i].score[0]+stu[i].score[1]+stu[i].score[2];
student%d:
(i+1),stu[i].score[3],(stu[i].score[3]/3));
voidpxs(structstudent*pt,int(*comp)(floata,floatb),intn)
structstudenttemp;
for(j=0;
(n-i-1);
if((*comp)(stu[j].score[3],stu[j+1].score[3]))
temp=stu[j];
stu[j]=stu[j+1];
stu[j+1]=temp;
putchar(stu[i].name[j]);
intds(floata,floatb)
returna<
b;
intas(floata,floatb)
returna>
voidpxi(structstudent*pt,intn)
if(stu[j].id>
stu[j+1].id)
voidpxn(structstudent*pt,intn)
if(strcmp(stu[j].name,stu[j+1].name)>
0)
voidseai(structstudent*pt,intn)
inti,j,con=0;
longid;
Inputthenumberyouwanttosearch:
id);
if(stu[j].score[3]<
stu[j+1].score[3])
if(stu[i].id==id)
%d\t%ld\t"
(i+1),stu[i].id);
for(j=0;
con=1;
break;
if(con==0)
Notfound!
voidsean(structstudent*pt,intn)
charname[10];
Inputthenameyouwanttosearch:
getchar();
fgets(name,sizeof(name),stdin);
if(strcmp(stu[i].name,name)==0)
voidana(structstudent*pt,intn)
inti,j,n1,n2,n3,n4,n5,n6;
n1=0;
n2=0;
n3=0;
n4=0;
n5=0;
n6=0;
if(stu[i].score[j]<
60)
n1+=1;
elseif(stu[i].score[j]<
70)
n2+=1;
80)
n3+=1;
90)
n4+=1;
=100)
n5+=1;
if(stu[i].score[j]==100)
n6+=1;
Forcourse%d:
(j+1));
<
60\t%d\t%.2f%%\n"
n1,100*(float)n1/n);
%d-%d\t%d\t%.2f%%\n"
60,69,n2,100*(float)n2/n);
70,79,n3,100*(float)n3/n);
80,89,n4,100*(float)n4/n);
90,100,n5,100*(float)n5/n);
%d\t%d\t%.2f%%\n"
100,n6,100*(float)n6/n);
voidwri(STUDENT*pt,intn)
FILE*fp;
if((fp=fopen("
student.txt"
"
w"
))==NULL)
exit(0);
//fprintf(fp,"
fprintf(fp,"
fprintf(fp,"
%c"
stu[i].name[j]);
fclose(fp);
savesuccessfully!
voidrea(STUDENT*pt,intn)
intm;
longa;
floatc,d,e,f,g;
charb[10];
//charhead[50];
r"
exit(0);
//fgets(head,50,fp);
//puts(head);
for(m=0;
m<
m++)
//printf("
scjdbfdsdj"
fscanf(fp,"
a);
a);
%10s"
b);
%s\t"
fscanf(fp,"
%f"
c);
%.0f\t"
c);
%f"
d);
d);
e);
e);
f);
f);
g);
%.0f\n"
g);
//printf("
jdhergjdkfnjherdgfdhb\n"
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 输入输出 排序 打印 学生 成绩单