C语言编写的简单学生成绩管理系统

C语言编写的简单学生成绩管理系统本文简介:C语言编写的简单学生成绩管理系统C语言编写的简单学生成绩管理系统include“stdio.h“include“stddef.h“include“stdlib.h“include“conio.h“/*屏幕操作函数*/include“string.h“defineMAX10typedefstructs
C语言编写的简单学生成绩管理系统本文内容:
C语言编写的简单学生成绩管理系统
C语言编写的简单学生成绩管理系统
include
“stdio.h“include
“stddef.h“include
“stdlib.h“include
“conio.h“/*屏幕操作函数*/
include
“string.h“define
MAX
10
typedef
struct
student{
char
name[MAX];
char
num[MAX];
char
sex[MAX];
int
age;
int
chinese;
int
mathematic;
int
english;
float
aver;
struct
studentnext;
}stu;
stuhead;
void
/*输出菜单*/
{
textcolorRED;
/*设置文本显示颜色为红色*/
textbackgroundGREEN;
/*设置背景颜色为绿色*/
window1,1,80,10;
/*
制作显示菜单的窗口*/
clrscr;
printf“\n“;
printf“************
welcome
to
use
student
manage****************\n“;
printf“***********************
MENU****************************\n“;
printf“*****
Enter
Record
“;
/*录入信息*/
printf“Statistics****\n“;
/*显示成绩*/
printf“*****
Quest
“;
/*查询*/
printf“Updata****\n“;
/*修改*/
printf“*****
Save
“;
/*保存到磁盘*/
printf“Display****\n“;
/*统计成绩*/
printf“*****
Fresh
“;
/*刷新*/
printf“Quit****\n“;
/*退出系统*/
printf“Maker
zhangwantong
Class045
Date2007.01.12
\n“;
printf“\n“;
}
void
cinstup1
/*录入学生信息/
{
printf“Enter
name\n“;
scanf“s“,p1-name;
printf“Enter
num\n“;
scanf“s“,p1-num;
printf“Enter
sex\n“;
scanf“s“,printf“Enter
age\n“;
scanf“d“,printf“Enter
score\n“;
printf“Enter
chinese\n“;
scanf“d“,printf“Enter
math\n“;
scanf“d“,printf“Enter
English\n“;
scanf“d“,p1-averp1-chinesep1-mathematicp1-english/3.0;
/*平均分*/
}
void
cindata
/*是否继续录入*/
{
stup1,*p2;
int
i1;
char
ch;
headstumallocsizeofstu;
p1head;
/*头指针*/
whilei
{
cinp1;
printf“Do
you
Want
to
Continueyes
or
no“;
chgetchar;
chgetchar;
ifchn||chN
{
i0;
p1-nextNULL;
}
else
{
p2p1;
p1stumallocsizeofstu;
p2-nextp1;
}
}
}
void
lookdatastup1
/*输出所有信息*/
{
printf“---------------------------------------------------------------------------\n“;
whilep1NULL
{
printf“Nums
“,p1-num;
printf“Names
“,p1-name;
printf“Sexs
“,p1-sex;
printf“Aged
“,p1-age;
/*
printf“\n“;/
printf“Chinesed
“,p1-chinese;
printf“Mathd
“,p1-mathematic;
printf“Englishd
“,p1-english;
printf“Averagef\n“,p1-aver;
printf“----------------------------------------------------------------------------\n“;
p1p1-next;
}
printf“----------------------------------------------------------------------------\n“;
}
/*已经完成的任务1.录入保存磁盘2.按姓名学号查询3.输出成绩表4.修改处理5.统计学生成绩*/
void
find1stup2
/*
按姓名查找信息/
{
char
name[20];
int
b0;
printf“Enter
the
name
of
the
student
you
want
to
find“;
scanf“s“,name;
whilep2NULL
{ifstrcmpname,p2-name0
{
printf“The
data
you
want
has
be
found\n“;
printf“--------------------------------------\n“;
printf“Nums\t“,p2-num;
printf“Names\t“,p2-name;
printf“sexs\t“,p2-sex;
printf“aged\t“,p2-age;
printf“\n“;
printf“Chinesed\t“,p2-chinese;
printf“Mathd\t“,p2-mathematic;
printf“Englishd\t“,p2-english;
printf“Averagef\n“,p2-aver;
printf“**************************************\n“;
b1;
}
p2p2-next;
}
ifb1
printf“Find
one\n“;
else
printf“Not
find\n“;
}
void
find2stup2
/*
按学号查找信息/
{
char
num[MAX];
int
b0;
printf“Enter
the
num
of
the
student
you
want
to
find“;
scanf“s“,whilep2NULL
{
ifstrcmpnum,p2-num0
{
printf“The
data
you
want
has
be
found\n“;
printf“--------------------------------------\n“;
printf“Nums\t“,p2-num;
printf“Names\t“,p2-name;
printf“Sexs\t“,p2-sex;
printf“Aged\t“,p2-age;
printf“\n“;
printf“Chinesed\t“,p2-chinese;
printf“Mathd\t“,p2-mathematic;
printf“Englishd\t“,p2-english;
printf“Averagef\n“,p2-aver;
printf“**************************************\n“;
b1;
}
p2p2-next;
}
ifb1
printf“Find
one\n“;
else
printf“Not
find\n“;
}
void
find
/*查询记录*/
{
int
i;
printf“Find
with
name
Find
with
num
Return\n“;
printf“Please
Enter
your
choice“;
scanf“d“,switchi
{
case
1
find1head;
break;
case
2
find2head;
break;
case
3
return;
}
}
void
update1stup2
/*按姓名修改*/
{
char
name[10];
int
b0;
printf“Enter
The
Name“;
scanf“s“,name;
whilep2NULL
{
ifstrcmpname,p2-name0
{
printf“Find
you
data\n“;
printf“Enter
the
new
name“;
scanf“s“,p2-name;
printf“Enter
the
num“;
scanf“s“,p2-num;
printf“Enter
the
sex“;
scanf“s“,p2-sex;
printf“Enter
the
age“;
scanf“d“,printf“Enter
the
chinese
score“;
scanf“d“,printf“Enter
the
math
score“;
scanf“d“,printf“Enter
the
english
score“;
scanf“d“,p2-averp2-chinesep2-mathematicp2-english;
printf“Success\n“;
b1;
}
p2p2-next;
}
ifb0
printf“Sorry
not
Find
data\n“;
else
printf“Finish\n“;
}
void
update2stup2
/*按学号修改*/
{
char
num[MAX];
int
b0;
printf“Enter
The
Num“;
scanf“s“,whilep2NULL
{
ifstrcmpnum,p2-num0
{
printf“Find
you
data\n“;
printf“Enter
the
new
name“;
scanf“s“,p2-name;
printf“Enter
the
num“;
scanf“s“,p2-num;
printf“Enter
the
sex“;
scanf“s“,p2-sex;
printf“Enter
the
age“;
scanf“d“,printf“Enter
the
chinese
score“;
scanf“d“,printf“Enter
the
math
score“;
scanf“d“,printf“Enter
the
english
score“;
scanf“d“,p2-averp2-chinesep2-mathematicp2-english/3.0;
printf“Success\n“;
b1;
}
p2p2-next;
}
ifb0
printf“Sorry
not
Find
data\n“;
else
printf“Finish\n“;
}
void
update
/*修改记录*/
{
int
i;
printf“Updata
with
name
Updata
with
num
Return\n“;
printf“Please
Enter
your
choice“;
scanf“d“,switchi
{
case
1
update1head;
break;
case
2
update2head;
break;
case
3
return;
}
}
void
savedstup2
/*保存到磁盘student.dat文件中*/
{
FILEfp;
char
file[16]“c\\student.dat“;
char
file1[]“num---name---sex--age-chinese-math-english-aver\n“;
iffpfile,“wt“NULL
{
printf“\nCannot
open
the
file
\n“;
return;
}
fprintffp,“s“,file1;
whilep2NULL
{
fprintffp,“s---“,p2-num;
fprintffp,“s---“,p2-name;
fprintffp,“s---“,p2-sex;
fprintffp,“d---“,p2-age;
fprintffp,“d---“,p2-chinese;
fprintffp,“d---“,p2-mathematic;
fprintffp,“d---“,p2-english;
fprintffp,“f\n“,p2-aver;
p2p2-next;
}
fclosefp;
printf“Saved
successed“;
}
void
statisticsstup2
/*统计学生成绩*/
{
FILEfp,*fp1;
char
file[16]“c\\stufile.dat“,file1[16]“c\\stugood.dat“;
iffpfile,“wt“NULL
{
printf“\nCannot
open
the
file
\n“;
return;
}
iffp1file1,“wt“NULL
{
printf“\nCannot
open
the
file
\n“;
return;
}
whilep2NULL
{
ifp2-chineseenglishmathematicnum;
fprintffp,“s--“,p2-name;
fprintffp,“s--“,p2-sex;
fprintffp,“d--“,p2-age;
fprintffp,“d--“,p2-chinese;
fprintffp,“d--“,p2-mathematic;
fprintffp,“d--“,p2-english;
fprintffp,“f\n“,p2-aver;
p2p2-next;
}
else
ifp2-chinese90
fprintffp1,“s--“,p2-name;
fprintffp1,“s--“,p2-sex;
fprintffp1,“d--“,p2-age;
fprintffp1,“d--“,p2-chinese;
fprintffp1,“d--“,p2-mathematic;
fprintffp1,“d--“,p2-english;
fprintffp1,“f\n“,p2-aver;
p2p2-next;
}
else
p2p2-next;
}
fclosefp;
fclosefp1;
printf“Saved
successed“;
}
void
print1
{
system“cls“;
}
/*清除整个屏幕*/
void
display2
/*显示不及格记录*/
{
FILEfp;
iffp“c\\STUFILE.DAT“,“r“NULL
{
printf“Cannot
open
the
file“;
return;
}
whilefeoffp
{
putcharfgetcfp;
}
printf“\bSuccess\n“;
}
void
display3
/*显示90分以上同学的记录*/
{
FILEfp;
iffp“c\\STUGOOD.DAT“,“r“NULL
{
printf“Cannot
open
the
file“;
return;
}
whilefeoffp
{
putcharfgetcfp;
}
printf“\bSuccess\n“;
}
void
display
/*显示记录*/
{
int
i;
printf“Display
All
Display
Good
Display
Flunk\n“;
printf“Plasce
Enter
your
choice“;
scanf“d“,switchi
{
case
1
lookdatahead;
break;
case
2
display3;
break;
case
3
display2;
break;
}
}
void
interface
/*启动界面*/
{
clrscr;
window20,5,60,15;
textattrBLUELIGHTGRAY4;
clrscr;
cputs“\n\n
Welcome
to
use
student
manage
system
“;
cputs“Maker
zhangwantong
“;
cputs“Class
04-5
“;
cputs“Date
2007.01.13
“;
cputs“Edit
V1.0
“;
cputs“Press
ENTER
key
.......“;
whilegetchar\n
;
return;
}
void
interface2
/*退出界面*/
{
print1;
window20,5,60,15;
textattr128BLUELIGHTGRAY4;
clrscr;
cputs“\n\n
cputs“Maker
zhangwantong
“;
cputs“Class
04-5
“;
cputs“Date
2007.01.13
“;
cputs“Edit
V1.0
“;
cputs“Press
ENTER
key
.......“;
whilegetchar\n
;
return;
}
void
main
{
int
choice;
int
i;
stup2;
interface;
print1;
print;
while1
{
printf“Enter
your
choice“;
scanf“d“,whilei8
{
printf“Enter
num
from
1
to
8\n“;
printf“Enter
your
choice“;
scanf“d“,}
switchi
{
case
1
cindata;
break;
case
2
statisticshead;
break;
case
3
find;
break;
case
4
update;
break;
case
5
savedhead;
break;
case
6
display;
break;
case
7
print1;
print;
break;
case
8
interface2;
exit1;
break;
}
printf“ENTER
to
continue“;
getchar;
whilegetchar\n
;
system“cls“;
print;
}
}
