学生成绩管理系统C语言Word格式文档下载.docx
《学生成绩管理系统C语言Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《学生成绩管理系统C语言Word格式文档下载.docx(30页珍藏版)》请在冰点文库上搜索。
charfilename[20],cz;
sound(0,0,sw);
while
(1)
{
file:
decorete(0,"
0e"
"
67"
27"
\"
学生成绩管理\"
欢迎您"
'
+'
0,0);
decorete(1,"
15"
输入数据文件名(默认:
.bin)"
'
<
退出程序:
exit;
列出文件:
list>
"
1,24);
printf("
>
);
fflush(stdin);
gets(filename);
\n"
if(strcmp(filename,"
exit"
)==0){sound(1,1,sw);
exit(0);
}
list"
)==0){sound(4,0,sw);
system("
dir/o:
d*.bin"
fflush(stdin);
getchar();
gotofile;
strcat(filename,"
.bin"
if((fp=fopen(filename,"
r"
))==NULL)
{
sound(2,0,sw);
decorete(1,"
文件不存在,是否创建该文件?
Y/y>
0,24);
printf("
--"
fflush(stdin);
cz=getchar();
if(cz=='
Y'
||cz=='
y'
fp=fopen(filename,"
w"
else
gotofile;
}
fclose(fp);
sound(4,0,sw);
cz='
;
while
(1)
display(filename);
07"
105"
35"
选择操作:
A.不及格学生名单B.排序C.修改D.删除E.增加S.<
开/关>
声音F.退出本文件R.删除文件N.退出程序"
0,50);
switch(cz)
{
case'
A'
:
sound(4,0,sw);
fail(filename);
break;
a'
B'
rank(filename);
b'
C'
alter(filename);
c'
D'
delet(filename);
sound(5,0,sw);
d'
E'
add(filename);
e'
F'
f'
r'
if(removefile(filename))gotofile;
R'
N'
sound(1,1,sw);
n'
S'
sw=~sw;
s'
}
}
voidadd(charfilename[])
inti,*rs,rsh;
floattemps;
structSTUDENT**p;
rs=&
rsh;
p=rdfile(filename,rs);
p[rsh]=(structSTUDENT*)malloc(sizeof(structSTUDENT));
p[rsh]->
xuhao=rsh+1;
printf("
\t\t请输入名字:
name:
fflush(stdin);
gets(p[rsh]->
name);
if(strlen(p[rsh]->
name)==0){printf("
\t\t\t"
gotoname;
strcpy(p[rsh]->
course[0],"
高等数学"
course[1],"
物理"
course[2],"
外语"
course[3],"
C语言"
course[4],"
德育"
\n\t\t\t\t输入各成绩:
for(i=0;
i<
5;
i++)
{printf("
\t\t\t\t\t%s:
p[rsh]->
course[i]);
score:
scanf("
%f"
&
temps);
if(temps>
=0&
&
temps<
=150)
p[rsh]->
score[i]=temps;
else
\t\t\t分数范围(0-150),重新输入:
gotoscore;
ave=avecal(p[rsh]);
if((fp=fopen(filename,"
a"
sound(3,0,sw);
无法打开相关文件!
exit(0);
fprintf(fp,"
%d.姓名:
%8s%8s:
%5.2f%5s:
%5.2f%6s:
%5.2f平均分:
%5.2f\n"
xuhao,p[rsh]->
name,p[rsh]->
course[0],p[rsh]->
score[0],p[rsh]->
course[1],p[rsh]->
score[1],p[rsh]->
course[2],p[rsh]->
score[2],p[rsh]->
course[3],p[rsh]->
score[3],p[rsh]->
course[4],p[rsh]->
score[4],p[rsh]->
ave);
fclose(fp);
structSTUDENT**rdfile(charfilename[],int*num)
intxh=0;
charch;
p=(structSTUDENT**)malloc(sizeof(structSTUDENT*));
system("
pause"
while((ch=fgetc(fp))!
=EOF)
fseek(fp,-1L,1);
p[xh]=(structSTUDENT*)malloc(sizeof(structSTUDENT));
p[xh]->
xuhao=xh+1;
fscanf(fp,"
%f%5s:
%f%6s:
%f平均分:
%f\n"
p[xh]->
xuhao,p[xh]->
name,p[xh]->
course[0],&
score[0],p[xh]->
course[1],&
score[1],p[xh]->
course[2],&
score[2],p[xh]->
course[3],&
score[3],p[xh]->
course[4],&
score[4],&
xh++;
*num=xh;
//最大的序号
returnp;
voiddisplay(charfilename[])
intxh;
int*rs,rsh;
107"
文件中的内容"
*'
for(xh=0;
xh<
*rs;
xh++)
%d.【%s】%8s:
p[xh]->
course[0],p[xh]->
course[1],p[xh]->
course[2],p[xh]->
course[3],p[xh]->
course[4],p[xh]->
score[4],p[xh]->
intalter(charfilename[])
intren,ke,i,*rs,rsh;
charc;
floattempg;
xiugai:
decorete(1,"
25"
将修改学生对应的序号:
"
scanf("
%d"
ren);
if(ren<
=0||ren>
rsh)
sound(2,0,sw);
\t不存在该学生的信息,重新输入<
Y/y,其他任意键退出修改>
:
c=getchar();
if(c=='
||c=='
)gotoxiugai;
return0;
ren=ren-1;
16"
0,42);
修改【%s】成绩:
\n\n\t[0]全部[1]%-12s[2]%-12s[3]%-12s[4]%-12s[5]%-12s\n"
p[ren]->
name,p[ren]->
course[0],p[ren]->
course[1],p[ren]->
course[2],p[ren]->
course[3],p[ren]->
course[4]);
cs:
0,48);
-->
ke);
if(ke<
0||ke>
5){sound(2,0,sw);
printf("
\t\t输入有误,重新输入:
gotocs;
if(ke!
=0){i=ke-1;
%s(%f):
course[i],p[ren]->
score[i]);
zs:
tempg);
if(tempg>
tempg<
p[ren]->
score[i]=tempg;
\t\t分数范围(0-150),重新输入:
gotozs;
=0){i=ke;
i=5;
p[ren]->
ave=avecal(p[ren]);
\t\t\t完成?
(Y/y)"
c=getchar();
if(c=='
{sound(4,0,sw);
无法保存!
else
for(i=0;
fprintf(fp,"
p[i]->
xuhao,p[i]->
name,p[i]->
course[0],p[i]->
score[0],p[i]->
course[1],p[i]->
score[1],p[i]->
course[2],p[i]->
score[2],p[i]->
course[3],p[i]->
score[3],p[i]->
course[4],p[i]->
score[4],p[i]->
sound(4,0,sw);
puts("
成功保存!
elsegotoxiugai;
return0;
intdelet(charfilename[])
inti,del,*rs,rsh;
charc,delc;
display(filename);
del:
decorete(1,"
将删除信息序号<
删除全部:
a>
%c"
delc);
if(delc==97||delc==65)
{sound(3,0,sw);
fail!
return0;
del=delc-48;
if(del<
1||del>
不存在该学生信息,是否继续?
Y/y,其他任意键退出删除>
c=getchar();
if(c=='
)gotodel;
return0;
{sound(3,0,sw);
if(i==del-1)i++;
if(i<
if(i>
del-1)p[i]->
xuhao--;
fprintf(fp,"
voidrank(charfilename[])
inti,j,k,*rs,rsh,max;
排序选项"
[0]姓名[1]高等数学[2]物理[3]外语[4]C语言[5]德育[6]平均分"
rank:
ch=getchar();
if(ch<
48||ch>
54)
{sound(2,0,sw);
\t\t\t无效选择!
重新输入:
gotorank;
i++)//rsh注意
max=i;
for(j=i;
j<
j++)
if(((ch-48)==0&
strcmp(p[max]->
name,p[j]->
name)>
0)||(((ch-48)>
0&
(ch-48)<
6)&
p[max]->
score[ch-49]<
p[j]->
score[ch-49])||((ch-48)==6&
ave<
ave))//后rsh,rsh-1,rsh-2...最大的标为max
{
strcpy(p[rsh]->
name,p[max]->
strcpy(p[max]->
strcpy(p[j]->
for(k=0;
k<
k++)
{
p[rsh]->
score[k]=p[max]->
score[k];
p[max]->
score[k]=p[j]->
p[j]->
score[k]=p[rsh]->
}
}
p[i]->
ave=avecal(p[i]);
i+1,p[i]->
voiddecorete(intclr,charcolor[],charwidth[],charheighth[],chartitle[],charedge,intcurn,intcurk)
inti,len,num;
char*mode;
len=strlen(width)+strlen(heighth)+strlen(title)+35;
mode=(char*)malloc(len);
if(clr==0)