C语言数据库学生成绩统计管理系统.docx

上传人:b****3 文档编号:10345510 上传时间:2023-05-25 格式:DOCX 页数:16 大小:18.49KB
下载 相关 举报
C语言数据库学生成绩统计管理系统.docx_第1页
第1页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第2页
第2页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第3页
第3页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第4页
第4页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第5页
第5页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第6页
第6页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第7页
第7页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第8页
第8页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第9页
第9页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第10页
第10页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第11页
第11页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第12页
第12页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第13页
第13页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第14页
第14页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第15页
第15页 / 共16页
C语言数据库学生成绩统计管理系统.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

C语言数据库学生成绩统计管理系统.docx

《C语言数据库学生成绩统计管理系统.docx》由会员分享,可在线阅读,更多相关《C语言数据库学生成绩统计管理系统.docx(16页珍藏版)》请在冰点文库上搜索。

C语言数据库学生成绩统计管理系统.docx

C语言数据库学生成绩统计管理系统

学生成绩统计管理系统

C语言数据结构课程作品

指导老师:

学生:

学号:

班级:

一、代码

#include

"stdafx.h"

#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(struct

voiddelate(struct

voidsaveda(struct

voidaddnew(struct

address*hp);address**head);address*tou);address**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("IIMenu:

II\n");

printf("II1:

printallthepersonalinformation.II\n");

printf("I2:

insertsomeoroneperson.I\n");

printf("I3:

reviresomeinformation.I\n");

printf("I4:

delatesomeinformationoraperson.I\n");

printf("I5:

exit.I\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:

\\information.dat","rb")))

{

return;

}

if(!

(gfhead=fopen("d:

\\grade.dat","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("II");

gotoxy(58,i+1+j);

printf("I");

}

gotoxy(1,i+6);

printf(n");

gotoxy(5,i+2);printf(gotoxy(30,i+2);printf(gotoxy(5,i+3);printf(gotoxy(30,i+3);printf(gotoxy(5,i+4);printf(gotoxy(5,i+5);printf(

"Nummber:

%s",hd->stu_num);"Name-spelling:

%s",hd->ename);

"Sex:

%s",hd->hname);

"Department:

%s",hd->depart);

"Address:

%s",hd->paddress);"Phonenummber:

%s\n",hd->phone);

printf(

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)=return

(*head)->next;

1

}

else

{

PRE->next=TARGE->next;}

if(!

TARGE)free(TARGE);

}

//*************voidrevise(

修改信息

structaddress*head)

{

intch;

charcinput[20];

charchoice;

structaddress*TARGE=NULL;structgrade*move;

do{system("cls");

printf("Inputthenameorstudentnummberyouwanttodelate:

\t");

fflush(stdin);

scanf("%s",cinput);

TARGE=head;

while(stricmp(cinput,TARGE->stu_num)&&stricmp(cinput,TARGE->ename)&&TARGE!

=NULL)

{

TARGE=TARGE->next;

}

if(TARGE==NULL)return;

printf("inputthecommand:

\n1->revisethesex;\t\t");printf("2->revisetheename;\n3->revisethestudentnummber;\t\t");

printf("4->revisethedepart;\n5->revisetheaddress;\t\t");

printf("6->revisethephone\n7->revisethegeography;\t\t");

printf("8-.revisethebiology\n9->revisethephysics;\t\t");printf("10->revisetheenglish;\n11->revisethemaths;\t\t");printf("12->torevisethechinese.\n");

fflush(stdin);

do{

scanf("%d",&ch);

}while(ch>12||ch<0);

switch(ch)

case1:

printf(scanf(

II

"entertheyoursexmaleorfemale:

\n"%s",TARGE->hname);

);

break;

case2:

printf(

scanf(

II

"enterthenameinSpell:

\n"%s",TARGE->ename);

);

break;

case3:

printf(

scanf(

II

"entertheStudentnummer:

\n%s",&TARGE->stu_num);

II

);

break;

case4:

printf(

scanf(

II

"inputyourDepartment:

\n"%s",TARGE->depart);

);

break;

case5:

printf(

scanf(

II

"inputyourpresentAddress:

\n%s",TARGE->paddress);

II

);

break;

case6:

printf(

scanf(

II

"inputyourmobienummer:

\n"%s",TARGE->phone);

);

break;

case7:

printf(

scanf(

II

"inputyourgeographyscore\n"%d",&(move->score));

);

break;

printf(scanf(

"inputyourbiologyscore\n""%d",&(move->score));

case8:

moveg(8,&move);

 

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:

\\information.dat","wb"))==NULL){

printf("fileerror!

\n");return;

}

if((gfhead=fopen("d:

\\grade.dat","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(scanf("%d",&pTempNode->head->score);gh=pTempNode->head;

sizeof(structgrade));

printf("inputmathsscore:

");

gh->next=(structgrade*)malloc(gh=gh->next;

scanf("%d",&gh->score);

sizeof(structgrade));

printf("inputEnglishscore:

");gh->next=(structgrade*)malloc(gh=gh->next;

scanf("%d",&gh->score);

sizeof(structgrade));

printf("inputphysicsscore:

");gh->next=(structgrade*)malloc(gh=gh->next;

scanf("%d",&gh->score);

sizeof(structgrade));

printf("inputbilolgyscore:

");

gh->next=(structgrade*)malloc(gh=gh->next;

scanf("%d",&gh->score);

sizeof(structgrade));

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获取输入等)。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2