C语言数据库学生成绩统计管理系统.docx
- 文档编号:28601513
- 上传时间:2023-07-19
- 格式:DOCX
- 页数:18
- 大小:198.01KB
C语言数据库学生成绩统计管理系统.docx
《C语言数据库学生成绩统计管理系统.docx》由会员分享,可在线阅读,更多相关《C语言数据库学生成绩统计管理系统.docx(18页珍藏版)》请在冰豆网上搜索。
C语言数据库学生成绩统计管理系统
C语言数据库-学生成绩统计管理系统(总13页)
学生成绩统计管理系统
C语言数据结构课程作品
指导老师:
学生:
学号:
班级:
一、代码
#include""
#include<>
#include<>
#include<>
#include<>
#include<>
#include<>
#include<>
structgrade
{
intscore;
structgrade*next;
};/*定义成绩的结构*/
structaddress{
charstu_num[4];/*学号*/
charhname[10];/*性别*/
charename[20];/*姓名*/
chardepart[30];/*系别*/
charpaddress[30];/*地址*/
charphone[13]/*联系电话*/;
structgrade*head;
structaddress*next;
};
voidloaddata(structaddress**had);
voidprintm(structaddress*head);
structaddress*seek(structaddress*head);
voidrevise(structaddress*hp);
voiddelate(structaddress**head);
voidsaveda(structaddress*tou);
voidaddnew(structaddress**had);
voidmoveg(inti,structgrade**move);
voidgotoxy(intx,inty);
voidsortp(structaddress**head);
intmain(void)
{
charch;
intc;
structaddress*head=NULL;
loaddata(&head);
do
{
system("cls");
printf("\n");
printf("学生信息与成绩统计:
\n");
printf("岳鹏程制作\n");
printf("===============================================\n");
printf("‖Menu:
‖\n");
printf("‖1:
printallthepersonalinformation.‖\n");
printf("‖2:
insertsomeoroneperson.‖\n");
printf("‖3:
reviresomeinformation.‖\n");
printf("‖4:
delatesomeinformationoraperson.‖\n");
printf("‖5:
exit.‖\n");
printf("===============================================\n");
printf("\tInput:
");
do
{
scanf("%d",&c);
getchar();
}while(c<0||c>6);
switch(c)
{
case1:
printm(head);
break;
case2:
addnew(&head);
break;
case3:
revise(head);
break;
case4:
delate(&head);
break;
break;
case5:
return0;
default:
break;
}
fflush(stdin);
printf("continueornot:
inputyorn\n");
ch=getchar();
saveda(head);
}while(ch=='y'||ch=='Y');
return0;
}
voidloaddata(structaddress**had)
{
FILE*afhead;
FILE*gfhead;
structaddress*p1,*hp1=NULL,*head=NULL;
structgrade*p2,*hp2=NULL;
inti=0;
intj=6;
if(!
(afhead=fopen("d:
\\","rb")))
{
return;
}
if(!
(gfhead=fopen("d:
\\","rb")))
{
return;
}
while(!
feof(afhead))
{
p1=(structaddress*)malloc(sizeof(structaddress));
fread(p1,sizeof(structaddress),1,afhead);
if(feof(afhead))
{
if(!
p1)
free(p1);
break;
}
if(i==0)
{
p1->next=NULL;
p1->head=NULL;
head=p1;
hp1=p1;
i++;
}/*使头指针指向第一个创建的节点*/
else
{
p1->next=NULL;
p1->head=NULL;
hp1->next=p1;
hp1=hp1->next;
}
}
*had=head;
p1=*had;
/*成绩是后进先出*/
while(!
feof(gfhead))
{
do
{
p2=(structgrade*)malloc(sizeof(structgrade));
fread(p2,sizeof(structgrade),1,gfhead);
p2->next=hp2;
hp2=p2;
j--;
}while(j>0);
if(!
feof(gfhead)&&p1!
=NULL)
{
p1->head=hp2;
p1=p1->next;
}
}
fclose(afhead);
fclose(gfhead);
}
voidprintm(structaddress*head)
{
inti=0,j;
floatiscore;
structgrade*ghd=NULL;
structaddress*hd=NULL;
hd=head;
system("cls");
if(hd==NULL)
{
printf("\t\t===Nosourseinthefile!
===");
return;
}
while(hd!
=NULL)
{
gotoxy(1,i+1);
printf("==========================================================\n");
for(j=0;j<6;j++)
{
gotoxy(1,i+1+j);
printf("‖");
gotoxy(58,i+1+j);
printf("‖");
}
gotoxy(1,i+6);
printf("\n==========================================================\n");
gotoxy(5,i+2);printf("Nummber:
%s",hd->stu_num);
gotoxy(30,i+2);printf("Name-spelling:
%s",hd->ename);
gotoxy(5,i+3);printf("Sex:
%s",hd->hname);
gotoxy(30,i+3);printf("Department:
%s",hd->depart);
gotoxy(5,i+4);printf("Address:
%s",hd->paddress);
gotoxy(5,i+5);printf("Phonenummber:
%s\n",hd->phone);
printf("\n==========================================================\n");
printf("\tHis\\Herscoreis:
\n");
ghd=hd->head;
printf("name地理生物物理英语数学语文\n");
printf("%s",hd->ename);
while(ghd!
=NULL)
{
printf("%d\t",ghd->score);
iscore+=ghd->score;
ghd=ghd->next;
}
printf("\n");
hd=hd->next;
i=i+10;
}
}
voiddelate(structaddress**head)
{
charcinput[20];
structaddress*PRE,*TARGE;
TARGE=(*head);
if(!
TARGE)
{
printf("=========Noanyinformation!
!
");
return;
}
fflush(stdin);
printf("Inputthenameorstudentnummberyouwanttodelate:
\t");
scanf("%s",cinput);
while(stricmp(cinput,TARGE->stu_num)&&stricmp(cinput,TARGE->ename)&&TARGE!
=NULL)
{
PRE=TARGE;
TARGE=TARGE->next;
}
if(TARGE==NULL)
{
printf("====Nothisinformation!
====\n");
return;
}
if(TARGE==(*head))
{
(*head)=(*head)->next;
return;
}
else
{
PRE->next=TARGE->next;
}
if(!
TARGE)
free(TARGE);
}
n");
fflush(stdin);
do{
scanf("%d",&ch);
}while(ch>12||ch<0);
switch(ch)
{
case1:
printf("entertheyoursexmaleorfemale:
\n");
scanf("%s",TARGE->hname);
break;
case2:
printf("enterthenameinSpell:
\n");
scanf("%s",TARGE->ename);
break;
case3:
printf("entertheStudentnummer:
\n");
scanf("%s",&TARGE->stu_num);
break;
case4:
printf("inputyourDepartment:
\n");
scanf("%s",TARGE->depart);
break;
case5:
printf("inputyourpresentAddress:
\n");
scanf("%s",TARGE->paddress);
break;
case6:
printf("inputyourmobienummer:
\n");
scanf("%s",TARGE->phone);
break;
case7:
printf("inputyourgeographyscore\n");
scanf("%d",&(move->score));
break;
case8:
moveg(8,&move);
printf("inputyourbiologyscore\n");
scanf("%d",&(move->score));
break;
case9:
moveg(9,&move);
printf("inputyourphysicsscore:
\n");
scanf("%d",&(move->score));
break;
case10:
moveg(10,&move);
printf("inputyourenglishscore:
\n");
scanf("%d",&(move->score));
break;
case11:
moveg(11,&move);
printf("inputyourmathsscore:
\n");
scanf("%d",&(move->score));
break;
case12:
moveg(12,&move);
printf("inputyourchinesescore:
\n");
scanf("%d",&(move->score));
move=move->next;
break;
default:
;
}
fflush(stdin);
printf("ifyouwanttoreviseotherdetailformationinputy\n");
scanf("%c",&choice);
}while(choice=='y'||choice=='Y');
}
voidmoveg(inti,structgrade**move)
{
for(i=i-7;i>0;i--)
{
(*move)=(*move)->next;
}
}
//*******************删除原来的记录并保存现在的ok!
voidsaveda(structaddress*tou)
{
FILE*afhead,*gfhead;
structgrade*gcu;
structaddress*tail=tou;
if((afhead=fopen("d:
\\","wb"))==NULL)
{
printf("fileerror!
\n");
return;
}
if((gfhead=fopen("d:
\\","wb"))==NULL)
{
printf("fileerror!
\n");
return;
}/*打开保存数据的文件*/
while(tail!
=NULL)
{
fwrite(tail,sizeof(structaddress),1,afhead);
gcu=tail->head;
while(gcu!
=NULL)
{
fwrite(gcu,sizeof(structgrade),1,gfhead);
gcu=gcu->next;
}
tail=tail->next;
}
fclose(afhead);
fclose(gfhead);
}
voidaddnew(structaddress**head)
{
structaddress*phead=NULL,*pTempNode=NULL;
structgrade*gh=NULL;
pTempNode=(structaddress*)malloc(sizeof(structaddress));
printf("inputnum(<10000):
");
scanf("%s",&pTempNode->stu_num);
printf("inputyoursexmaleorfemale:
");
scanf("%s",pTempNode->hname);
printf("inputnameinspelling:
");
scanf("%s",pTempNode->ename);
printf("inputyourdepartment:
");
scanf("%s",pTempNode->depart);
printf("inputyouraddress:
");
scanf("%s",pTempNode->paddress);
printf("inputyourphonenummber:
");
scanf("%s",pTempNode->phone);
pTempNode->next=NULL;
pTempNode->head=NULL;
fflush(stdin);
printf("inputchinese:
");
pTempNode->head=(structgrade*)malloc(sizeof(structgrade));
scanf("%d",&pTempNode->head->score);
gh=pTempNode->head;
printf("inputmathsscore:
");
gh->next=(structgrade*)malloc(sizeof(structgrade));
gh=gh->next;
scanf("%d",&gh->score);
printf("inputEnglishscore:
");
gh->next=(structgrade*)malloc(sizeof(structgrade));
gh=gh->next;
scanf("%d",&gh->score);
printf("inputphysicsscore:
");
gh->next=(structgrade*)malloc(sizeof(structgrade));
gh=gh->next;
scanf("%d",&gh->score);
printf("inputbilolgyscore:
");
gh->next=(structgrade*)malloc(sizeof(structgrade));
gh=gh->next;
scanf("%d",&gh->score);
printf("inputgeographyscore:
");
gh->next=(structgrade*)malloc(sizeof(structgrade));
scanf("%d",&(gh->next->score));
gh->next->next=NULL;
if((*head)==NULL)
{
(*head)=pTempNode;
}
else
{
phead=(*head);
while(phead!
=NULL&&phead->next!
=NULL)
{
phead=phead->next;
}
phead->next=pTempNode;
}
printf("youhaveaddanewperson!
");
}
二、设计思路
“任意增删”实现主要是靠链表。
“学生”是一种支持链表的结构体。
全局有一个“学生”的链表。
然后每个“学生”object下面又有各自的一个“科目”的链表。
(printf打印菜单文字内容,scanf获取输入等)。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 语言 数据库 学生 成绩 统计 管理 系统
![提示](https://static.bdocx.com/images/bang_tan.gif)