c语言小组实验.docx

上传人:b****6 文档编号:8182406 上传时间:2023-01-29 格式:DOCX 页数:52 大小:46.20KB
下载 相关 举报
c语言小组实验.docx_第1页
第1页 / 共52页
c语言小组实验.docx_第2页
第2页 / 共52页
c语言小组实验.docx_第3页
第3页 / 共52页
c语言小组实验.docx_第4页
第4页 / 共52页
c语言小组实验.docx_第5页
第5页 / 共52页
点击查看更多>>
下载资源
资源描述

c语言小组实验.docx

《c语言小组实验.docx》由会员分享,可在线阅读,更多相关《c语言小组实验.docx(52页珍藏版)》请在冰豆网上搜索。

c语言小组实验.docx

c语言小组实验

河北工程大学

《学生信息管理系统》

课程项目设计报告书

题目:

学生信息管理系统

专业:

工商管理

班级及组号:

1001班第六组

组长学号姓名:

100130126孙亭亭

组员学号姓名:

100130123张颖

100130124张光超

100130125张晓敏

指导老师:

程慧芳

设计时间:

2011年6月10日~2011年6月16日

 

1.设计目的与内容要求

目的:

设计一学生信息管理系统设计

内容:

学生信息包括:

姓名,地址,手机号码,qq号码,生日等。

试设计一学生信息管理系统,使之能提供以下功能:

1.系统以菜单方式工作。

.

2.学生信息录入功能---输入。

3.学生信息浏览功能---输出。

2.小组分工和每位组员的贡献说明

张颖:

负责会议安排,讨论内容,确定课题题目。

张光超:

负责查找资料,及参考文献,搜集材料。

张晓敏:

负责心得体会,以及程序调试。

孙亭亭:

负责设计,功能分析,效果贴图。

3.需求分析与功能设计

程序设计组成框图:

 

姓名:

地址:

学号:

手机号:

出生月:

出生日:

 

功能设计:

根据主菜单选择是否进入程序(利用if语句实现)

进入学生信息输入界面(利用scanf输入while循环)

源程序:

#include

#include

#include

#include

#include"conio.h"

structstudent

{

charname[20];

charadd[20];

charnum[11];

chartel[12];

charshorttel[8];

charqq[11];

charmonth[3];

charday[3];

structstudent*next;

};

structstudent*creat(structstudent*head);

structstudent*record();

structstudent*search(structstudent*head,charch);

structstudent*insert(structstudent*head);

structstudent*load();

voidprintall(structstudent*temp);

voidprint(structstudent*temp);

voidmainmenu();

voideditmenu(structstudent*head);

voidsearchmenu(structstudent*head);

voidamendmenu(structstudent*temp);

voidsavefile(structstudent*head);

structstudent*delmenu(structstudent*head);

intcheck(charstrs[],intlen,intz);

charfilename[256];

structstudent*creat(structstudent*head)

{

structstudent*p1,*p2=NULL;

p1=p2=(structstudent*)malloc(sizeof(structstudent));

p1=record();

head=p1;

while(p1!

=NULL)

{

charch;

printf("\n******CreatSuccess!

!

******\n");

printf("\nEntertocontinue,otherkeytoreturn!

\n");

ch=getch();

if(ch!

=13)break;

p2->next=p1;

p2=p1;

p1=(structstudent*)malloc(sizeof(structstudent));

p1=record();

}

p2->next=p1;

p2=p1;

p2->next=NULL;

printf("\n\nFinsh!

!

Pressanykeytoeditit!

");

getch();

returnhead;

}

intcheck(charstrs[],intlen,intz)

{

inti=0;

if(strlen(strs)>len){printf("Illegelinput!

Pleaseinputagain!

\n");return0;}

if(z==1)

while(strs[i]!

='\0')

{

if(strs[i]<48||strs[i]>58){printf("Illegelinput!

Pleaseinputagain!

\n");return0;}

i++;

}

return1;

}

structstudent*record()

{

structstudent*temp;

charstrs[30];

temp=(structstudent*)malloc(sizeof(structstudent));

do

{

printf("Pleaseinputthestudent'sname:

");

scanf("%s",strs);

}while(!

check(strs,20,0));

strcpy(temp->name,strs);

do

{

printf("Pleaseinputthestudent'saddress:

");

scanf("%s",strs);

}while(!

check(strs,20,0));

strcpy(temp->add,strs);

do

{

printf("Pleaseinputthestudent'snumber:

");

scanf("%s",strs);

}while(!

check(strs,10,1));

strcpy(temp->num,strs);

do

{

printf("Pleaseinputthestudent'smobilenumber:

");

scanf("%s",strs);

}while(!

check(strs,11,1));

strcpy(temp->tel,strs);

do

{

printf("Pleaseinputthestudent'sshorttelnumber:

");

scanf("%s",strs);

}while(!

check(strs,6,1));

strcpy(temp->shorttel,strs);

do

{

printf("Pleaseinputthestudent'sqqnumber:

");

scanf("%s",strs);

}while(!

check(strs,10,1));

strcpy(temp->qq,strs);

do

{

printf("Pleaseinputthestudent'sbornmonth:

");

scanf("%s",strs);

}while(!

check(strs,2,1));

strcpy(temp->month,strs);

do

{

printf("Pleaseinputthestudent'sbornday:

");

scanf("%s",strs);

}while(!

check(strs,2,1));

strcpy(temp->day,strs);

fflush(stdin);

returntemp;

}

structstudent*load()

{

structstudent*head,*temp,*temp1;

FILE*fp;

charch;

inti=0;

charstrs[20];

head=NULL;

temp1=(structstudent*)malloc(sizeof(structstudent));

printf("Pleaseinputthefilename:

(student)");

scanf("%s",filename);

if((fp=fopen(filename,"rt"))==NULL)

{

printf("Systemcan'tfindthefile!

");

getch();

returnNULL;

}

ch=fgetc(fp);

while(ch!

=EOF)

{

temp=(structstudent*)malloc(sizeof(structstudent));

while(ch!

=-2)

{

strs[i]=ch;

i++;

ch=fgetc(fp);

}

strs[i]='\0';

i=0;

strcpy(temp->name,strs);

ch=fgetc(fp);

while(ch!

=-2)

{

strs[i]=ch;

ch=fgetc(fp);

i++;

}

strs[i]='\0';

i=0;

strcpy(temp->add,strs);

ch=fgetc(fp);

while(ch!

=-2)

{

strs[i]=ch;

ch=fgetc(fp);

i++;

}

strs[i]='\0';

i=0;

strcpy(temp->num,strs);

ch=fgetc(fp);

while(ch!

=-2)

{

strs[i]=ch;

ch=fgetc(fp);

i++;

}

strs[i]='\0';

i=0;

strcpy(temp->tel,strs);

ch=fgetc(fp);

while(ch!

=-2)

{

strs[i]=ch;

ch=fgetc(fp);

i++;

}

strs[i]='\0';

i=0;

strcpy(temp->shorttel,strs);

ch=fgetc(fp);

while(ch!

=-2)

{

strs[i]=ch;

ch=fgetc(fp);

i++;

}

strs[i]='\0';

i=0;

strcpy(temp->qq,strs);

ch=fgetc(fp);

while(ch!

=-2)

{

strs[i]=ch;

ch=fgetc(fp);

i++;

}

strs[i]='\0';

i=0;

strcpy(temp->month,strs);

ch=fgetc(fp);

while(ch!

=-2)

{

strs[i]=ch;

ch=fgetc(fp);

i++;

}

strs[i]='\0';

i=0;

strcpy(temp->day,strs);

ch=fgetc(fp);

if(head==NULL)head=temp;

else

temp1->next=temp;

temp1=temp;

}

temp->next=NULL;

fclose(fp);

printf("Loadsuccess!

Pressanykeytocontinue!

\n");

getch();

returnhead;

}

voidsavefile(structstudent*head)

{

FILE*fp;

inti=0;

if(filename[0]=='\0'){printf("Pleaseinputthefilename:

");scanf("%s",filename);}

fp=fopen(filename,"wt");

while(head!

=NULL)

{

while(head->name[i]!

='\0')

{

fputc(head->name[i],fp);

i++;

}

i=0;

fputc(254,fp);

while(head->add[i]!

='\0')

{

fputc(head->add[i],fp);

i++;

}

i=0;

fputc(254,fp);

while(head->num[i]!

='\0')

{

fputc(head->num[i],fp);

i++;

}

i=0;

fputc(254,fp);

while(head->tel[i]!

='\0')

{

fputc(head->tel[i],fp);

i++;

}

i=0;

fputc(254,fp);

while(head->shorttel[i]!

='\0')

{

fputc(head->shorttel[i],fp);

i++;

}

i=0;

fputc(254,fp);

while(head->qq[i]!

='\0')

{

fputc(head->qq[i],fp);

i++;

}

i=0;

fputc(254,fp);

while(head->month[i]!

='\0')

{

fputc(head->month[i],fp);

i++;

}

i=0;

fputc(254,fp);

while(head->day[i]!

='\0')

{

fputc(head->day[i],fp);

i++;

}

i=0;

fputc(254,fp);

head=head->next;

}

fclose(fp);

printf("Savesuccess!

");

getch();

}

voidprint(structstudent*temp)

{

printf("\n");

printf("********************************************************************************");

printf("Thestudent'snameis:

%s\n",temp->name);

printf("Thestudent'saddressis:

%s\n",temp->add);

printf("Thestudent'snumberis:

%s\n",temp->num);

printf("Thestudent'smobilenumberis:

%s\n",temp->tel);

printf("Thestudent'sshorttelnumberis:

%s\n",temp->shorttel);

printf("Thestudent'sqqnumberis:

%s\n",temp->qq);

printf("Thestudent'sbirthdayis:

%s,%sth\n",temp->month,temp->day);

printf("********************************************************************************");

}

voidprintall(structstudent*head)

{

inti=0;

if(head==NULL)

{

printf("Systemisempty!

\n");

return;

}

while(head!

=NULL)

{

i++;

print(head);

head=head->next;

if(i>1){getch();i=0;}

}

}

structstudent*insert(structstudent*head)

{

structstudent*temp=head,*temp1=NULL;

charch;

while

(1)

{

if(head==NULL)

{

head=creat(head);

returnhead;

}

while(temp->next!

=NULL)

{

temp=temp->next;

}

temp1=(structstudent*)malloc(sizeof(structstudent));

temp1=record();

temp->next=temp1;

temp1->next=NULL;

printf("\nInsertthestudent'ssuccess!

\n");

printf("PressEntertocontinue!

Otherkeytoreturn!

\n");

ch=getch();

if(ch==13);

else

returnhead;

}

}

structstudent*search(structstudent*head,charch)

{

charstrs[20];

while

(1)

{

switch(ch)

{

case'a':

printf("Pleaseinputthestudent'sname:

");

scanf("%s",strs);

while(head!

=NULL)

{

if(strcmp(head->name,strs)==0)

{

returnhead;

}

head=head->next;

}

printf("Systemcan'tfind%s'simformation!

",strs);

returnNULL;

case'b':

printf("Pleaseinputthestudent'saddress:

");

scanf("%s",strs);

while(head!

=NULL)

{

if(strcmp(head->add,strs)==0)

{

returnhead;

}

head=head->next;

}

printf("Systemcan'tfindtheaddress!

");

returnNULL;

case'c':

printf("Pleaseinputthestudent'snumber:

");

scanf("%s",strs);

while(head!

=NULL)

{

if(strcmp(head->num,strs)==0)

{

returnhead;

}

head=head->next;

}

printf("Systemcan'tfindthenumber!

");

returnNULL;

case'd':

printf("Pleaseinputthestudent'smobilephonenumber:

");

scanf("%s",strs);

while(head!

=NULL)

{

if(strcmp(head->tel,strs)==0)

{

returnhead;

}

head=head->next;

}

printf("Systemcan'tfindthemobilephonenumber!

");

returnNULL;

case'e':

printf("Pleaseinputthestudent'sshortnumber:

");

scanf("%s",strs);

while(head!

=NULL)

{

if(strcmp(head->shorttel,strs)==0)returnhead;

head=head->next;

}

printf("Systemcan'tfindtheshortnumber!

");

returnNULL;

case'f':

printf("Pleaseinputthestudent'sqqnumber:

");

scanf("%s",strs);

while(head!

=NULL)

{

if(strcmp(head->qq,strs)==0)returnhead;

head=head->next;

}

printf("Systemcan'tfindtheqqnumber!

");

returnNULL;

case'g':

{

charday[3];

printf("Pleaseinputthemonth:

");

scanf("%s",strs);

printf("Pleaseinputtheday:

");

scanf("%s",day);

while(head!

=NULL)

{

if(strcmp(head->month,strs)==0&&strcmp(head->day,day)==0)returnhead;

head=head->next;

}

printf("Systemcan'tfindthebirthday!

");

returnNULL;

}

default:

;

}

}

}

voidmainmenu()

{

structstudent*head=NULL;

charch;

puts("\nWelcometoStudentImformationSystem!

\n");

puts("********************************************************************************");

puts("Mainmenu\n");

puts("[a]Creatnewstudentimformationfile;\n");

puts("[b]Loadthestudentimformationfile;\n");

puts("[c]About.....\n");

puts("[d]ExitSystem!

");

puts("\n********************************

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

当前位置:首页 > 初中教育 > 中考

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1