校运动会管理系统报告C语言(含完整代码)

时间:2019-05-15 04:43:40下载本文作者:会员上传
简介:写写帮文库小编为你整理了多篇相关的《校运动会管理系统报告C语言(含完整代码)》,但愿对你工作学习有帮助,当然你在写写帮文库还可以找到更多《校运动会管理系统报告C语言(含完整代码)》。

第一篇:校运动会管理系统报告C语言(含完整代码)

目录 陈

一、程序分析与设计.......................................................................................................................2

二、流程图.......................................................................................................................................4

三、源程序清单...............................................................................................................................4

四、调试过程.................................................................................................................................15

五、程序有待改进的地方.............................................................................................................19

六、本次实习的收获和建议.........................................................................................................19 附录.................................................................................................................错误!未定义书签。

一、程序分析与设计

(标题四号宋体加黑,正文五号宋体,行间距-固定值18,首行缩进2字符)

1.题目描述

初始化输入:N-参赛院系总数,M-男子竞赛项目数,W-女子竞赛项目数;即要求输入一些基础数据,如院系名称,每个院系参赛选手及选手编号。竞赛项目名称与代号。这些数据存储在文本文件中,不需要每次都单条录入。各项目名次取法有如下几种:

取前4名:第1名得分6,第2名得分4,第3名得分2,第4名得分1; 由程序提醒用户填写比赛结果,输入各项目获奖运动员的信息。

所有信息记录完毕后,用户可以查询各个院系或个人的比赛成绩,生成团体总分报表,查看参赛院系信息、获奖运动员、比赛项目信息等。2.需求分析

根据题目要求应提供键盘式菜单实现功能选择,还应提供信息的输入操作,由于在程序中提供查询功能所以应有显示、查找等操作。3.总体设计

根据上面的需求分析,可以将这个系统的设计分为

1、信息输入模块

2、比赛结果录入模块

3、查询模块。具体校际运动会管理系统分为 信息的输入、结果的输入、学校各个项目的得分的查寻、总体报表的生成。4.详细设计(1)主函数

主函数一般设计的比较简洁,只提供输入,处理和输出部分的函数调用。其中功能模块用菜单方式选择。(2)密码登陆函数

首先进入欢迎界面,提示用户输入密码进入系统,密码输入次数限制为三次,三次输入错误则退出系统,登陆成功显示菜单栏(3)菜单函数

提醒用户根据要求选择功能,以及多次功能选取(4)输入函数

进入该功能后提醒用户输入相应信息,即数据结构,数据结构采用结构体的形式,选手结构体成员包括选手的姓名、编号、各项目的成绩排名、选手所在学院等。(5)查找函数

提醒用户输入运动员的姓名或编号,根据姓名或编号逐一比对信息,若条件满足则输出该选手的数据,若不满足则返回‘你要找的运动员未找到’(6)排序函数

根据运动员的百米成绩进行冒泡排序,并输出结果(7)修改函数

提醒用户输入运动员的姓名,根据姓名逐一比对信息,若找到则提供修改选项,对数据进行覆盖(8)得分计算函数

根据用户输入各项成绩排名,进行得分运算 并得出学院排名(9)删除函数 用于输入信息的删除(10)插入函数 用于输入新的信息(11)保存函数

将用户输入的信息保存到文本文件中(12)显示函数 显示用户保存的信息

二、流程图

三、源程序清单

(此部分采用小五号宋体,行间距-固定值14)#include #include #include #include #include #define load sizeof(student)#define N 7 void read();void save();

int size=3;struct student {

void input()//输入原始数据// {

} void find()//查找函数// {

system(“cls”);printf(“t************查找界面************n”);char fs[20];read();printf(“输入你要查找运动员的号码或姓名:”);scanf(“%s”,&fs);for(int i=0;i

printf(“%st%st%dt%dt%dt%dt%sn”,stu[i].num,stu[i].name,stu[i].scorem,stu[i].scor

} else if(strcmp(stu[i].name,fs)==0){ printf(“你要找的运动员已找到:n”);break;if(strcmp(stu[i].num,fs)==0){ printf(“你要找的运动员已找到:n”);printf(“该生的号码,姓名,100米成绩,铅球成绩,跳高成绩,跳远成绩,系名:n”);printf(“%st%st%dt%dt%dt%dt%sn”,stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);scanf(“%s%s%d%d%d%d%s”,&stu[i].num,&stu[i].name,&stu[i].scorem,&stu[i].scoreq,&stu[i].printf(“输出运动员号码,姓名,100成绩,铅球成绩,跳高成绩,跳远成绩,系名:n”);for(i=0;i

} printf(“该生的号码,姓名,100米成绩,铅球成绩,跳高成绩,跳远成绩,系名:n”);printf(“%st%st%dt%dt%dt%dt%sn”,stu[i].num,stu[i].name,stu[i].scorem,stu[i].scor

} } else {

} printf(“你要找的运动员未找到:n”);printf(“该运动员缺赛或不存在!”);break;break;eq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);void paixu()//排序函数// {

} void xiugai()//修改函数// {

printf(“%st%st%dt%dt%dt%dt%sn”,stu[i].num,stu[i].name,stu[i].scorem,stu[i].scorsystem(“cls”);printf(“t************修改界面************n”);char ch2[20],c;char num[10],name[20];int scorem,scoreq,scoreg,scorey,i;char ximing[20];printf(“原始数据:n”);/*for(int i=0;i

system(“cls”);printf(“t************排序界面************n”);printf(“对一百米的成绩排序:n”);for(int i=0;i

} printf(“排序后:n”);for(i=0;i

} if(stu[i].scorem

} temp=stu[i];stu[i]=stu[j];stu[j]=temp;

eq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);*/

read();printf(“输入你要修改运动员的姓名:”);scanf(“%s”,ch2);for(i=0;i

if(strcmp(stu[i].name,ch2)==0){ printf(“1.修改号码n2.修改姓名n3.修改100米成绩n4.修改铅球成绩n5.修改跳高成绩n6.修改跳远成绩n7.修改系名n”);

scanf(“%d”,&c);switch(c){ case 1: { printf(“请输入你修改的运动员号码:”);scanf(“%s”,&num);strcpy(stu[i].num,num);break;} case 2: { printf(“输入你修改的运动员姓名:n”);scanf(“%s”,&name);strcpy(stu[i].name,name);break;} case 3: { printf(“输入你修改的运动员100米成绩:”);scanf(“%d”,&scorem);stu[i].scorem=scorem;break;} case 4: { printf(“输入你修改运动员铅球成绩:”);scanf(“%d”,&scoreq);stu[i].scoreq=scoreq;break;} case 5: { printf(“输入你修改运动员跳高成绩:”);scanf(“%d”,&scoreg);stu[i].scoreq=scoreq;break;} case 6: {

}

} printf(“输入你修改运动员跳远成绩:”);scanf(“%d”,&scorey);stu[i].scorey=scorey;break;case 7: {

} default: } printf(“修改后的运动员数据:n”);for(int i=0;i

if(stu[i].scoreq==1)y=3;else if(stu[i].scoreq==2)y=2;else if(stu[i].scoreq==3)y=1;else y=0;printf(“%st%st%dt%dt%dt%dt%sn”,stu[i].num,stu[i].name,stu[i].scorem,stu[i].scorread();printf(“各系的得分总分排序:n”);for(i=0;i

if(stu[i].scorem==1)x=3;else if(stu[i].scorem==2)x=2;else if(stu[i].scorem==3)x=1;else x=0;eq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);*/ system(“cls”);printf(“t************得分界面************n”);int x,y,z,w,o,p,q,i;char ch1[20]=“ruanjian”,ch2[20]=“shumei”,ch3[20]=“guangdian”;printf(“原始数据:n”);/*for(int i=0;i

}

} if(stu[i].scoreg==1)z=3;else if(stu[i].scoreg==2)z=2;else if(stu[i].scoreg==3)z=1;else z=0;if(stu[i].scorey==1)w=3;else if(stu[i].scorey==2)w=2;else if(stu[i].scorey==3)w=1;else w=0;for(i=0;i

} if(strcmp(stu[i].ximing,ch1)==0){

} else if(strcmp(stu[i].ximing,ch2)==0){

} else if(strcmp(stu[i].ximing,ch3)==0){

} q=x+y+z+w;printf(“光电系总得分:%dn”,q);

p=x+y+z+w;printf(“数媒系总得分:%dn”,p);o=x+y+z+w;printf(“软件系总得分:%dn”,o);void shancchu()//删除函数// {

printf(“%st%st%dt%dt%dt%dt%sn”,stu[i].num,stu[i].name,stu[i].scorem,stu[i].scorread();printf(“输入你要删除的运动员的姓名:n”);scanf(“%s”,&ch1);for(i=0;i

if(strcmp(stu[i].name,ch1)==0){ for(int j=i;j

} {

} } stu[j]=stu[j+1];printf(“删除后的运动员数据:n”);for(i=0;i

void charu()//插入函数

system(“cls”);int a;printf(“t************插入界面************n”);printf(“请输入要插入的运动员个数:”);scanf(“%d”,&a);for(int j=0;j

} printf(“输入要插入的运动员数据:n”);printf(“号码:”);scanf(“%s”,&stu[size].num);printf(“姓名:”);scanf(“%s”,&stu[size].name);printf(“100米成绩:”);scanf(“%d”,&stu[size].scorem);printf(“铅球成绩:”);scanf(“%d”,&stu[size].scoreq);printf(“跳高成绩:”);scanf(“%d”,&stu[size].scoreg);printf(“跳远成绩:”);scanf(“%d”,&stu[size].scorey);printf(“系名:”);scanf(“%s”,&stu[size].ximing);for(int i=0;i

for(int j=i+1;j

if(stu[i].scorem

} temp=stu[i];stu[i]=stu[j];stu[j]=temp;size++;printf(“插入后运动员数据:n”);for(int i=0;i

} void save(){

} void read(){

} printf(“%st%st%dt%dt%dt%dt%sn”,stu[i].num,stu[i].name,stu[i].scorem,stu[i].scor} fclose(fp);

//关闭文件 eq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);fscanf(fp,“%st%st%dt%dt%dt%dt%sn”,&stu[i].num,&stu[i].name,&stu[i].scorem,&stu[i].scoreq,&stu[i].scoreg,&stu[i].scorey,&stu[i].ximing);for(int i=0;i

if((fp=fopen(“e:xiao.txt”,“r”))==NULL){

} fscanf(fp,“运动员号码,姓名,100成绩,铅球成绩,跳高成绩,跳远成绩,系名:n”);printf(“打不开文件Cannot open the filen”);return;

//若打不开则返回菜单

//为输出打开一个二进制文件,为只fprintf(fp,“%st%st%dt%dt%dt%dt%sn”,stu[i].num,stu[i].name,stu[i].scorem,stu[i].fclose(fp);

//关闭文件 scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);printf(“保存成功....Save the file successfully!n”);FILE *fp;

//定义指向文件的指针

//char outfile[20];//printf(“输出文件例如:c:score Enter outfile name,for example c:scoren”);//scanf(“%s”,outfile);if((fp=fopen(“e:xiao.txt”,“w”))==NULL){

} printf(“n保存中...Saving the file......n”);//fprintf(fp,“运动员号码,姓名,100成绩,铅球成绩,跳高成绩,跳远成绩,系名:n”);for(int i=0;i

//若打不开则返回菜单

//为输出打开一个二进制文件,为只

//保存数据到文件函数 printf(“%st%st%dt%dt%dt%dt%sn”,stu[i].num,stu[i].name,stu[i].scorem,stu[i].scorsave();eq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);写方式

写方式 int login(char password[]){

//密码校对函数*********** static char key[10]=“12345”;if(strcmp(password,key)==0)return 1;else return 0;}

void Logon(){

} if(s==0){

count++;while(count!=3){

printf(“请再次输入密码:n”);scanf(“%s”,password);s=login(password);if(s==1)char a;printf(“n”);printf(“****************欢迎进入校运动会管理界面****************n”);printf(“********************************************************n”);printf(“********************登陆请按回车键**********************n”);printf(“********************************************************n”);printf(“n”);scanf(“%c”,&a);if(a=='n'){

FILE *fp;char password[10];int count=0,s;printf(“您有三次输入机会!nn”);printf(“请输入密码:n”);scanf(“%s”,password);s=login(password);if(s==1){

fp=fopen(“C:UsersAdministratorDesktop实训password.txt”,“w”);fprintf(fp,“%s”,password);fclose(fp);system(“CLS”);printf(“密码正确!n”);printf(“********************************************************n”);printf(“***************************欢迎进入*********************n”);printf(“********************************************************nnn”);

//比较输入字符和系统设定的密码是否相同

}

}

}

} {

fp=fopen(“C:UsersAdministratorDesktop实训fprintf(fp,”%s“,password);fclose(fp);system(”CLS“);printf(”密码正确!n“);password.txt”,“w”);printf(“********************************************************n”);printf(“***************************欢迎进入*********************n”);printf(“********************************************************n”);} if(s==0)count++;return;if(count==3)printf(“你已经错误输入3次,系统退出!n”);exit(0);else exit(1);void menu(){

int ch1;char ch2;struct tm *pt;/*定义时间结构体*/ time_t t;t=time(NULL);pt=localtime(&t);/*读取系统日期并把它放到结构体中*/ do{

{ printf(“tt当前系统日期:%d-%d-%dn”,pt->tm_year+1900,pt->tm_mon+1,pt->tm_mday);printf(“======================菜单=====================n”);printf(“ 1.输入 printf(” 3.排序 printf(“ 5.得分 printf(” 7.插入 printf(“ 9.显示

2.查找 4.修改 6.删除 8.保存

n”);n“);n”);n“);/*显示当前系统日期*/

0.退出n”);printf(“=n”);printf(“请选择功能<1-8>:[ ]bb”);//getchar();scanf(“%d”,&ch1);switch(ch1)

}

}

case 1:

input();break;find();break;paixu();break;xiugai();break;defen();break;shancchu();break;charu();break;save();break;read();break;exit(0);printf(“未进行任何操作!”);case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 0: default: printf(“n”);printf(“想要继续操作请按yn”);getchar();scanf(“%2c”,&ch2);

//条件判断 }while(ch2=='y');

void main(){

} system(“color 3f”);//Logon();menu();

四、调试过程

在程序运行的过程中,出现了很多的错误。有很复杂的问题,也不乏许多低级的错误。在写入文件的时候,首先我用的是fwrite,而在读入文件的时候用的是fread,后来才发现这两个语句都只是对二进制的文件进行操作,实际上我们要用到的fscanf、fprintf这两个语句。修改完的代码 FILE *fp;//定义指向文件的指针 if((fp=fopen(“e:xiao.txt”,“r”))==NULL)

//为输出打开一个二进制文件,为只写方式

fscanf(fp,“%st%st%dt%dt%dt%dt%sn”,&stu[i].num,&stu[i].name,&stu[i].scorem,for(int i=0;i

}

fscanf(fp,“运动员号码,姓名,100成绩,铅球成绩,跳高成绩,跳远成绩,系名:n”);printf(“打不开文件Cannot open the filen”);return;

//若打不开则返回菜单

&stu[i].scoreq,&stu[i].scoreg,&stu[i].scorey,&stu[i].ximing);printf(“%st%st%dt%dt%dt%dt%sn”,stu[i].num,stu[i].name,stu[i].scorem,stu[i].scoreq,stu[i].scoreg,stu[i].scorey,stu[i].ximing);} fclose(fp);

//关闭文件 做菜单功能多次选择时,令用户输入字符进行选择,然而程序总是退出,后来才知道‘n’也被算入用户输入的字符内,要在字符输入后添加getchar()才能避免菜单失效 做显示函数,屏幕显示异常,总是反复显示相同数据和乱码,原来是结构体初始化,当中的数组已经存储了数据,在显示时与函数同时输出了,要再定义一个相同的数组应用它输出。(1)登陆

(2)菜单

(3)输入

(4)查找

(5)排序

(6)修改

(7)得分

(8)删除

(9)插入

(10)保存

(11)退出

五、程序有待改进的地方

六、本次实习的收获和建议

通过这次课程设计我得出一个结论:知识必须通过应用才能实现其价值!有些东西以为学会了,但真正到用的时候才发现是两回事,所以我认为只有到真正会用的时候才是真的学会了。同时在设计的过程中发现了自己的不足之处,对一些前面学过的知识理解得不够深刻,掌握得不够牢固,比如说指针。编程时要养成良好的风格,注意相同内容的缩进和对齐。这样做,可以使程序代码出错的情况下,可以快速并且便捷的查找到错误的行,利于很好的修改。

在整个设计中我懂得了许多东西,也培养了我独立工作的能力,树立了对自己工作能力的信心,相信会对今后的学习工作生活有非常重要的影响。而且大大提高了动手的能力,使我充分体会到了在创造过程中探索的艰难和成功时的喜悦。虽然这个设计做的也不太好,但是在设计过程中所学到的东西是这次课程设计的最大收获和财富,使我终身受益。

在本次实践中,给我印象最为深刻的是在文件删除程序的编译过程中,这个程序将是关键。老天不会让我太过顺利,他在这最后的时刻设置的障碍,但是我鼓起勇气,到处查找资料,终于让我实现了这个函数,谢谢给我指点迷津的朋友和同学。对我而言,知识上的收获重要,精神上的丰收是可喜的。挫折是一份财富,经历是一份拥有。这次实际操作必将成为我们人生旅途上一个非常美好的回忆!

第二篇:c语言火车票管理系统基本代码

#include #include #include #include

int shoudsave = 0;int count1 = 0, count2 = 0, mark = 0, mark1 = 0;structtrain {

};structman {

};typedefstructnode { structtrain data;structnode * next;char num[10];char name[10];int bookNum;char num[10];char city[10];char takeoffTime[10];char receiveTime[10];int price;int bookNum;}Node, *Link;typedefstructpeople { structman data;structpeople*next;}bookMan, *bookManLink;void printInterface(){

puts(“********************************************************”);puts(“* Welcome to use the system of booking tickets *”);puts(“********************************************************”);puts(“* You can choose the operation: *”);puts(“* 1:Insert a train information *”);puts(“* 2:Inquire a train information *”);puts(“* 3:Book a train ticket *”);

} puts(“* 4:Update the train information *”);puts(“* 5:Advice to you about the train *”);puts(“* 6:save information to file *”);puts(“* 7:quit the system *”);puts(“********************************************************”);/*添加一个火车信息*/

void InsertTraininfo(Linklinkhead){

structnode *p, *r, *s;char num[10];r = linkhead;s = linkhead->next;while(r->next!= NULL){

printf(“please input the number of the train(0-return)”);scanf(“%s”, num);if(strcmp(num, “0”)== 0){

} p =(structnode*)malloc(sizeof(structnode));strcpy(p->data.num, num);printf(“Input the city where the train will reach:”);scanf(“%s”, p->data.city);printf(“Input the time which the train take off:”);scanf(“%s”, p->data.takeoffTime);printf(“Input the time which the train receive:”);scanf(“%s”, &p->data.receiveTime);printf(“Input the price of ticket:”);scanf(“%d”, &p->data.price);printf(“Input the number of booked tickets:”);if(strcmp(s->data.num, num)== 0){

} s = s->next;printf(“the train '%s'has been born!n”, num);return;break;while(s)r = r->next;while(1)

scanf(“%d”, &p->data.bookNum);

p->next = NULL;

r->next = p;

r = p;

shoudsave = 1;} } void printTrainInfo(structnode*p){ puts(“nThe following is the record you want:”);printf(“>>number of train: %sn”, p->data.num);printf(“>>city the train will reach: %sn”, p->data.city);printf(“>>the time the train take off: %snthe time the train reach: %sn”p->data.takeoffTime, p->data.receiveTime);printf(“>>the price of the ticket: %dn”, p->data.price);printf(“>>the number of booked tickets: %dn”, p->data.bookNum);}

structnode * Locate1(Linkl, charfindmess[], charnumorcity[]){ Node*r;if(strcmp(numorcity, “num”)== 0){

r = l->next;

while(r)

{

if(strcmp(r->data.num, findmess)== 0)

return r;

r = r->next;

} } elseif(strcmp(numorcity, “city”)== 0){

r = l->next;

while(r)

{

if(strcmp(r->data.city, findmess)== 0)

return r;

r = r->next;

} } , } return 0;void QueryTrain(Linkl){

Node *p;int sel;char str1[5], str2[10];if(!l->next){

} printf(“Choose the way:n>>1:according to the number of train;n>>2:according to the scanf(”%d“, &sel);if(sel == 1){

} elseif(sel == 2){

printf(”Input the city:“);scanf(”%s“, str2);p = Locate1(l, str2, ”city“);if(p){ } printTrainInfo(p);printf(”Input the the number of train:“);scanf(”%s“, str1);p = Locate1(l, str1, ”num“);if(p){ } else {

} mark1 = 1;printf(”nthe file can't be found!“);printTrainInfo(p);printf(”There is not any record!“);return;city:n”);

}

} else {

} mark1 = 1;printf(“nthe file can't be found!”);void BookTicket(Linkl, bookManLinkk){

Node*r[10], *p;char ch, dem;bookMan*v, *h;int i = 0, t = 0;char str[10], str1[10], str2[10];v = k;while(v->next!= NULL)v = v->next;printf(“Input the city you want to go: ”);scanf(“%s”, &str);p = l->next;while(p!= NULL){

} printf(“nnthe number of record have %dn”, i);for(t = 0;t

{

printf(“ndo you want to book it?<1/0>n”);scanf(“%d”, &ch);if(ch == 1){ h =(bookMan*)malloc(sizeof(bookMan));printTrainInfo(r[t]);printf(“ntttSorry!Can't find the train for you!n”);if(i == 0)else if(strcmp(p->data.city, str)== 0){

} p = p->next;r[i] = p;i++;

}

}

} printf(“Input your name: ”);scanf(“%s”, &str1);strcpy(h->data.name, str1);printf(“Input your id: ”);scanf(“%s”, &str2);strcpy(h->data.num, str2);printf(“Input your bookNum: ”);scanf(“%d”, &dem);h->data.bookNum = dem;h->next = NULL;v->next = h;v = h;printf(“nLucky!you have booked a ticket!”);getch();shoudsave = 1;bookMan*Locate2(bookManLinkk, charfindmess[]){

} /*修改火车信息*/ void UpdateInfo(Linkl){

Node*p;char findmess[20], ch;if(!l->next){ printf(“nthere isn't record for you to modify!n”);bookMan*r;r = k->next;while(r){

} return 0;if(strcmp(r->data.num, findmess)== 0){

} r = r->next;mark = 1;return r;

} } return;else {

} QueryTrain(l);if(mark1 == 0){

} else mark1 = 0;printf(“nDo you want to modify it?n”);getchar();scanf(“%c”, &ch);if(ch == 'y');{

} printf(“nInput the number of the train:”);scanf(“%s”, findmess);p = Locate1(l, findmess, “num”);if(p){

} else printf(“tttcan't find the record!”);printf(“Input new number of train:”);scanf(“%s”, &p->data.num);printf(“Input new city the train will reach:”);scanf(“%s”, &p->data.city);printf(“Input new time the train take off”);scanf(“%s”, &p->data.takeoffTime);printf(“Input new time the train reach:”);scanf(“%s”, &p->data.receiveTime);printf(“Input new price of the ticket::”);scanf(“%d”, &p->data.price);printf(“Input new number of people who have booked ticket:”);scanf(“%d”, &p->data.bookNum);printf(“nmodifying record is sucessful!n”);shoudsave = 1;void AdvicedTrains(Linkl){

} void SaveTrainInfo(Linkl){

FILE*fp;Node*p;int count = 0, flag = 1;fp = fopen(“D: rain.txt”, “wb”);if(fp == NULL){

} p = l->next;while(p){

if(fwrite(p, sizeof(Node), 1, fp)== 1){

} p = p->next;count++;printf(“the file can't be opened!”);return;Node*r;char str[10];int mar = 0;r = l->next;printf(“Iuput the city you want to go: ”);scanf(“%s”, str);while(r){

} if(mar == 0)printf(“ntttyou can't book any ticket now!n”);if(strcmp(r->data.city, str)== 0 && r->data.bookNum < 200){

} r = r->next;mar = 1;printf(“nyou can select the following train!n”);printf(“nnplease select the fourth operation to book the ticket!n”);printTrainInfo(r);

}

} else {

} flag = 0;break;if(flag){

} fclose(fp);printf(“the number of the record which have been saved is %dn”, count);shoudsave = 0;void SaveBookmanInfo(bookManLinkk){

FILE*fp;bookMan*p;int count = 0, flag = 1;fp = fopen(“D:man.txt”, “wb”);if(fp == NULL){

} p = k->next;while(p){

} if(flag){ printf(“the number of the record which have been saved is %dn”, count);if(fwrite(p, sizeof(bookMan), 1, fp)== 1){

} else {

} flag = 0;break;p = p->next;count++;printf(“the file can't be opened!”);return;

} } shoudsave = 0;fclose(fp);int main(){

FILE*fp1, *fp2;Node*p, *r;char ch1, ch2;Link l;bookManLink k;bookMan*t, *h;int sel;l =(Node*)malloc(sizeof(Node));l->next = NULL;r = l;k =(bookMan*)malloc(sizeof(bookMan));k->next = NULL;h = k;fp1 = fopen(“D: rain.txt”, “ab+”);if((fp1 == NULL)){

} while(!feof(fp1)){

} fclose(fp1);fp2 = fopen(“D:man.txt”, “ab+”);if((fp2 == NULL)){ p =(Node*)malloc(sizeof(Node));if(fread(p, sizeof(Node), 1, fp1)== 1){

} p->next = NULL;r->next = p;r = p;count1++;printf(“can't open the file!”);return 0;

} printf(“can't open the file!”);return 0;while(!feof(fp2)){

} fclose(fp2);while(1){

system(“cls”);printInterface();printf(“please choose the operation: ”);scanf(“%d”, &sel);system(“cls”);if(sel == 8){

} switch(sel)if(shoudsave == 1){

} printf(“nThank you!You are welcome toon”);break;getchar();printf(“nthe file have been changed!do you want to save it(y/n)?n”);scanf(“%c”, &ch1);if(ch1 == 'y' || ch1 == 'Y'){

} SaveBookmanInfo(k);SaveTrainInfo(l);t =(bookMan*)malloc(sizeof(bookMan));if(fread(t, sizeof(bookMan), 1, fp2)== 1){

} t->next = NULL;h->next = t;h = t;count2++;

}

} { case 1:

} printf(“nplease press any key to continue.......”);getch();InsertTraininfo(l);break;QueryTrain(l);break;BookTicket(l, k);break;UpdateInfo(l);break;AdvicedTrains(l);break;SaveTrainInfo(l);SaveBookmanInfo(k);break;return 0;case 2: case 3: case 4: case 5: case 6: case 7: return 0;

第三篇:C语言课程设计代码

#include “stdio.h” #include #include #define LEN sizeof(struct course)struct course { int cID;char name[50];float credit;int semester;struct course *next;};

void main(){ int n=0;struct course *head=NULL;void insert(struct course **head,struct course *cou);void Print(struct course **head,int *n);void Modify(struct course **head,int *n);void Require(struct course **head);void Creat(struct course **head,int *n);void Delete(struct course **head,int *n);void Fun(struct course **head,int *n);

Fun(&head,&n);}

void insert(struct course **head,struct course *cou){ struct course *p0,*p1,*p2;p2=p1=*head;p0=cou;if(*head){

while((p0->semester>p1->semester)&&(p1->next))

{

p2=p1;

p1=p1->next;

}

if(p0->semester

semester)

{

if(*head==p1)*head=p0;

else p2->next=p0;

p0->next=p1;}

else

{

if(p0->semester==p1->semester){ while((p0->cID>p1->cID)&&(p1->next)&&(p0->semester==p1->semester))

{

} if(p0->semester!=p1->semester){

} else {

if(p0->cID<=p1->cID){

if(*head==p1)*head=p0;else p2->next=p0;p2=p1;p1=p1->next;p2->next=p0;p0->next=p1;

p0->next=p1;

}

else

{p1->next=p0;p0->next=NULL;}

}

}

else

{p1->next=p0;p0->next=NULL;}

} } else

{

*head=p0;

p0->next=NULL;} }

void Print(struct course **head,int *n){ struct course *p;p=*head;if(*head){

if(*n==1)printf(“nThis %d record is:n”,*n);

else printf(“nThese %d records are:n”,*n);

printf(“semester cID

name

creditn”);

do

{ printf(“%-10d%-10d%-18s%-12.1f n”,p->semester,p->cID,p->name,p->credit);

p=p->next;

}while(p!=NULL);} else printf(“nList null!n”);}

void Modify(struct course **head,int *n){ struct course *p,*p2;int cID;if(*head){

Print(head,n);while(1){ printf(“nPlease input the cID which you want to modify:”);

scanf(“%d”,&cID);p2=p=*head;while(p->next&&(cID!=p->cID)){

p2=p;

p=p->next;} if(cID==p->cID){

printf(“Please input the new cID(1~60):”);

scanf(“%d”,&p->cID);

while(p->cID<0||p->cID>60)

{

printf(“nError!”);

printf(“nPlease input the new cID(1~60):”);

scanf(“%d”,&p->cID);

}

printf(“Please input the new semester(1~8):”);

scanf(“%d”,&p->semester);while(p->semester<0||p->semester>8)

{

printf(“nError!”);

printf(“nPlease input the new semester(1~8):”);

scanf(“%d”,&p->semester);

}

printf(“Please input the new credit:”);

scanf(“%f”,&p->credit);

printf(“Please input the new name:”);

scanf(“%s”,p->name);

if(p==*head)*head=p->next;

else p2->next=p->next;

insert(head,p);

break;

}

else printf(“%d not been found!n”,cID);

} } else {printf(“nList null!n”);} }

void Require(struct course **head){ struct course *p;float sum=0;int sem,i=0;printf(“nPlease input the semester which is required:”);

scanf(“%d”,&sem);p=*head;while(p){

if(sem==p->semester)

{

i++;if(i==1)printf(“nsemester cID

name

creditn”);printf(“%-10d%-10d%-18s%-12.1f n”,p->semester,p->cID,p->name,p->credit);

sum=sum+p->credit;

}

p=p->next;} printf(“The sum of credit in this term is:%.1fn”,sum);}

void Creat(struct course **head,int *n){ struct course *p1;while(1){

p1=(struct course *)malloc(LEN);

printf(“Please input the cID(1~60):”);

scanf(“%d”,&p1->cID);

while(p1->cID<0||p1->cID>60)

{

printf(“nError!”);

printf(“nPlease input the cID(1~60):”);

scanf(“%d”,&p1->cID);

}

if(p1->cID==0)break;

printf(“Please input the semester(1~8):”);

scanf(“%d”,&p1->semester);

while(p1->semester<0||p1->semester>8)

{

printf(“nError!”);

printf(“nPlease input the semester(1~8):”);scanf(“%d”,&p1->semester);

}

} } printf(“Please input the credit:”);scanf(“%f”,&p1->credit);printf(“Please input the name:”);scanf(“%s”,p1->name);insert(head,p1);*n=*n+1;printf(“nYou can continue until the cID is ”0“!n”);Print(head,n);void Delete(struct course **head,int *n){

struct course *p1,*p2;int cID;Print(head,n);if(*head){ printf(“Please input the cID of the course which you want to delete:”);scanf(“%d”,&cID);p1=*head;

while(cID!=p1->cID&&p1->next!=NULL)

{

p2=p1;

p1=p1->next;

}

if(cID==p1->cID)

{

if(p1==*head)*head=p1->next;

else p2->next=p1->next;

printf(“Have delete cID:%dn”,cID);

*n=*n-1;

}

else printf(“%d not been found!n”,cID);} }

void Fun(struct course **head,int *n){ char num;

while(1)

{

system(“cls”);

puts(“**************** Main Menu ******************”);

puts(“* 1.Add Records

2.Print Records

*”);

puts(“* 3.Delete Records

4.Modify Records *”);

puts(“* 5.Require Records 6.Exit

*”);

printf(“Please input your choice: ”);

scanf(“%d”,&num);

switch(num)

{

case 1:Creat(head,n);break;

case 2:Print(head,n);break;

case 3:Delete(head,n);break;

case 4:Modify(head,n);break;

case 5:Require(head);break;case 6:exit(0);break;

default: break;

}

printf(“nPress ”Enter“ to continue!”);getchar();getchar();

} }

第四篇:校级运动会管理系统c语言程序

#include #include #include #include

#define SIZE 9 #define N

#define WM

void bsxm();

//比赛项目 void csxx();

//参赛学校 void ttzf();

//团体总分 void Information();void main();void menu();void printf_back();void saveathlete();void saveprogram();void saveschool();void savescore();void Search();

int i;FILE *fp1,*fp2,*fp3,*fp4;

struct athlete

//定义运动员信息 { char univ[5];char name[8];char prog[15];

char mingci[5];int score;} at[SIZE];

struct xuexiao

//定义学校信息 { char univ[5];char prog[15];int num_athlete;} xx[N];

struct program { char prog[5];int quming;

char ath1[5];char ath2[5];char univ1[5];char univ2[5];} pro[WM];

//定义项目信息

struct zongfen

//定义学校得分信息 { char univ[5];char prog1[5];char prog2[5];char prog3[5];int score1;int score2;int score3;int total_score;} zf[N];

void Information()//进入信息录入系统选择系统子函数 {

int n,w;

do

{

puts(“nnn”);

puts(“tt***^__^

Welcome to load 信息录入 system!

^__^***n”);

puts(“tt*************************MENU*************************n”);

puts(“tt******** 1.saveathlete

**************n”);//运动员姓名录入

puts(“tt******** 2.saveschool

**************n”);//运动员学校录入

puts(“tt******** 3.saveprogram()

**************n”);//参加项目录入

puts(“tt******** 4.back

**************n”);//退出

puts(“tt******************************************************n”);

printf(“Choic your number(1-4):[ ]bb”);

scanf(“%d”,&n);

if(n<1||n>4)

{

w=1;

printf(“nntt----------------------DATAERROR!----------------------nnn”);

getchar();

}

else w=0;

}

while(w==1);

switch(n)

{

case 1 : saveathlete();break;// 保存运动员信息子函数

case 2 : saveschool();break;//保存学校信息子函数

case 3 : saveprogram();break;//保存项目比赛信息子函数

case 4 : exit(0);

} }

void saveathlete(){ //保存运动员信息子函数

printf(“n请输入各项目获奖运动员的信息:”);

for(i=0;i

printf(“n请输入第%d个运动员的信息:n”,i+1);

printf(“姓名:”);

scanf(“%s”,at[i].name);

printf(“学校:”);

scanf(“%s”,at[i].univ);

printf(“参赛项目:”);

scanf(“%s”,at[i].prog);printf(“名次:”);scanf(“%s”,at[i].mingci);

printf(“得分:”);

scanf(“%d”,&at[i].score);

} fp1=fopen(“ath”,“w”);

for(i=0;i

printf(“File write error!n”);}

fclose(fp1);fp1=fopen(“ath”,“r”);

printf(“n现在各运动员的信息如下:nn”);

printf(“姓名

学校

项目

名次

得分n”);for(i=0;i

fread(&at[i],sizeof(struct athlete),1,fp1);

printf(“%-10s%-10s%-18s%-10s%dn”,at[i].name,at[i].univ,at[i].prog,at[i].mingci,at[i].score);} fclose(fp1);printf_back();}

void saveschool()//保存学校信息子函数 { printf(“n请输入各参赛学校的信息:”);

for(i=0;i

printf(“n请输入第%d个学校的信息:n”,i+1);

printf(“学校:”);

scanf(“%s”,xx[i].univ);

printf(“参赛的项目:”);

scanf(“%s”,xx[i].prog);

printf(“参赛者数:”);

scanf(“%d”,&xx[i].num_athlete);}

fp3=fopen(“xxiao”,“w”);for(i=0;i

if(fwrite(&xx[i],sizeof(struct xuexiao),1,fp3)!=1)

printf(“File write error!n”);} fclose(fp3);

printf_back();}

void saveprogram()//保存项目比赛信息子函数 { printf(“n请输入关于比赛项目的信息:”);

for(i=0;i

printf(“n请输入第%d项比赛的信息:n”,i+1);printf(“项目:”);scanf(“%s”,pro[i].prog);printf(“取分情况:”);scanf(“%d”,&pro[i].quming);printf(“参赛者1:”);scanf(“%s”,pro[i].ath1);printf(“所属学校:”);scanf(“%s”,pro[i].univ1);printf(“参赛者2:”);scanf(“%s”,pro[i].ath2);

printf(“所属学校:”);

scanf(“%s”,pro[i].univ2);}

fp4=fopen(“pr”,“w”);for(i=0;i

if(fwrite(&pro[i],sizeof(struct program),1,fp4)!=1)

printf(“File write error!n”);} fclose(fp4);

printf_back();}

void savescore()//保存学校得分情况子函数 { printf(“N-参赛学校总数,M-男子竞赛项目数,W-女子竞赛项目数。n”);printf(“W.100-女子一百米比赛,M.100-男子一百米,M.200-男子两百米。n”);printf(“n各项名次得分权值如下:n”);printf(“取前三名:第一名5分

第二名3分

第三名2分n”);

printf(“n请输入各学校的得分情况:”);

for(i=0;i

printf(“n请输入第%d个学校的得分情况:n”,i+1);

printf(“学校:”);scanf(“%s”,zf[i].univ);

printf(“参赛项目1:”);scanf(“%s”,zf[i].prog1);printf(“得分:”);scanf(“%d”,&zf[i].score1);printf(“参赛项目2:”);scanf(“%s”,zf[i].prog2);printf(“得分:”);scanf(“%d”,&zf[i].score2);

printf(“参赛项目3:”);scanf(“%s”,zf[i].prog3);

printf(“得分:”);

scanf(“%d”,&zf[i].score3);

zf[i].total_score=zf[i].score1+zf[i].score2+zf[i].score3;}

fp2=fopen(“zfen”,“w”);for(i=0;i

if(fwrite(&zf[i],sizeof(struct zongfen),1,fp2)!=1)

printf(“File write error!n”);} fclose(fp2);

printf_back();}

void Search()//进入查询系统子函数 { int n,w2;do

{

puts(“tt***^__^

Welcome to load search system!

^__^***n”);

puts(“tt*************************MENU*************************n”);

puts(“tt******** 1.search ttzf **************n”);//查看团体总分

puts(“tt******** 2.search csxx **************n”);//查看参赛学校信息!

puts(“tt******** 3.search bsxm **************n”);//查看比赛项目信息!

puts(“tt******** 4.Exit

**************n”);//退出

puts(“tt***************************************n”);

printf(“Choose your number(1-4):[ ]bb”);

scanf(“%d”,&n);

if(n<1||n>4)

{

w2=1;

printf(“nntt----------------------DATAERROR!----------------------nnn”);

getchar();

}

else w2=0;} while(w2==1);switch(n){ case 1: ttzf();break;case 2: csxx();break;case 3: bsxm();break;case 4: exit(0);break;default: printf(“未进行任何操作!”);}

}

void ttzf()//查看学校团体总分子函数 { fp2=fopen(“zfen”,“r”);

printf(“n各学校的团体总分情况如下:nn”);

printf(“学校

参赛项目

总分n”);for(i=0;i

fread(&zf[i],sizeof(struct zongfen),1,fp2);

printf(“%-8s%s,%s,%-12s%-12dn”,zf[i].univ,zf[i].prog1,zf[i].prog2,zf[i].prog3,zf[i].total_score);} fclose(fp2);printf_back();}

void csxx()//查看参赛学校信息子函数 {

fp3=fopen(“xxiao”,“r”);

printf(“n各参赛学校的情况如下:nn”);

printf(“学校

参赛项目

参赛者数n”);for(i=0;i

fread(&xx[i],sizeof(struct xuexiao),1,fp3);

printf(“%-8s%-20s%-12dn”,xx[i].univ,xx[i].prog,xx[i].num_athlete);} fclose(fp3);

printf_back();}

void bsxm()//查看比赛项目子函数 {

fp4=fopen(“pr”,“r”);

printf(“n各比赛项目的信息如下:nn”);

printf(“项目

取分情况

参赛者1 所属学校

参赛者2 所属学校n”);for(i=0;i

fread(&pro[i],sizeof(struct program),1,fp4);

printf(“%-12s%-10d%-10s%-12s%-10s%-12sn”,pro[i].prog,pro[i].quming,pro[i].ath1,pro[i].univ1,pro[i].ath2,pro[i].univ2);} fclose(fp4);printf_back();}

void main(){ menu();

}

void menu()//主菜单程序 { int n,w1;do {

puts(“tt***^__^

Welcome to load sports system!

^__^***n”);

puts(“tt*************************MENU*************************n”);

puts(“tt******** 1.Enter the information

**************n”);//进入信息录入

puts(“tt******** 2.Score

**************n”);//进入比赛结果录入

puts(“tt******** 3.Search

**************n”);//进入查询功能

puts(“tt******** 4.Exit

**************n”);//退出

puts(“tt******************************************************n”);

printf(“Choose your number(1-4):[ ]bb”);

scanf(“%d”,&n);

if(n<1||n>4)

{

w1=1;

printf(“nntt----------------------DATAERROR!----------------------nnn”);

getchar();

}

else w1=0;} while(w1==1);

switch(n)

{

case 1:Information();break;//输入信息

case 2:savescore();break;//比赛结果录入

case 3:Search();break;//查询模块

case 4:exit(0);

}

}

//公共函数

void printf_back(){ int w;printf(“nntSUCCESSFUL!nn”);printf(“What do you want to do next?nnt1).exit t2).menu:[ ]bb”);scanf(“%d”,&w);if(w==1)exit(0);else menu();}

第五篇:C语言课程设计《高速公路联网收费系统》代码

作者:吴侠志

就读院校:东莞理工学院

#include “stdafx.h” #define NUM 4 #define max_len 8 #include #include #include #include #include #include

char *mytime(struct tm *timeptr);

//获取系统时间的函数 void Delay(int n);//延时函数 char *filename(int startkey);void initialize(struct car *cars,int num,FILE *fp);///初始化函数 int refer(struct car *cars,int startkey);//查询

int km[10]={0,0,82,162,288,368,391,514,800,867};

/* 记录各站与首站的里程,单位:km */ double price[6]={0.0,0.6,1.2,1.8,2.4,3.0};

/* 记录各类车的里程价位,单位:元/辆公里 */ char *address[10]={“0”,“湛江”,“茂名”,“阳江”,“开平”,“佛山”,“广州”,“深圳”,“汕头”,“汾水”};char *kind[6]={“特殊车”,“一类车”,“二类车”,“三类车”,“四类车”,“五类车”};

struct car { int card_num;

/* 卡号 */ int car_type;int station_in;char time_in[26];int station_out;char time_out[26];char is_in;double money;int flag;}cars[9*NUM+1];

int num=0;int pass=0;int main(int argc, char* argv[]){ int i,key,choice,j,k,m,size;double pay,money;char enter,pwd[max_len+1],password[max_len+1],ch;FILE *fp;fp=fopen(“标记.txt”,“a+”);fclose(fp);

fp=fopen(“记录.txt”,“a+”);

fclose(fp);

printf(“t欢迎登录广东同三高速公路联网收费系统n”);printf(“┏━━━━━━━━━━━━━━━━━━━━┓n”);printf(“┃

1.湛江

2.茂名

3.阳江

┃n”);printf(“┃

4.开平

5.佛山

6.广州

┃n”);printf(“┃

7.深圳

8.汕头

9.汾水关

┃n”);printf(“┗━━━━━━━━━━━━━━━━━━━━┛n”);printf(“请选择所在站点,并输入该序号:”);int startkey;while(1){

fflush(stdin);

while(scanf(“%d%c”,&startkey,&enter)==0 || enter!='n')

{

printf(“terror!!input again:”);

fflush(stdin);

}

if(startkey==1 || startkey==2 || startkey==3 || startkey==4 || startkey==5 || startkey==6 || startkey==7 || startkey==8 || startkey==9)

{

break;

}

else

{

printf(“terror!!input again:”);

continue;

} } printf(“初始化中……”);

fp=fopen(“标记.txt”,“a+”);fscanf(fp,“%d”,&num);fclose(fp);

fp=fopen(“password.txt”,“a+”);fscanf(fp,“%d”,&pass);fclose(fp);if(pass==0)

{

} fp=fopen(“password.txt”,“w+”);fprintf(fp,“%d”,88888888);fclose(fp);

fp=fopen(“记录.txt”,“a+”);rewind(fp);initialize(cars,num,fp);

fclose(fp);Delay(5);time_t timer;struct tm *tblock,*a;timer=time(NULL);a=localtime(&timer);while(1){ system(“cls”);fflush(stdin);printf(“所在地:%s站n登录时间:%sn”,address[startkey],mytime(a));printf(“┏━━━━━━━━━━━━━━━━━━━━━┓n”);printf(“┃

1.发卡

┃n”);printf(“┃

2.检卡并收费

┃n”);printf(“┃

3.查询

┃n”);printf(“┃

4.注销并退出系统

┃n”);printf(“┃

5.退出系统

┃n”);printf(“┗━━━━━━━━━━━━━━━━━━━━━┛n”);printf(“请选择,并输入序号:”);while(1){

while(scanf(“%d%c”,&key,&enter)==0 || enter!='n')

{

printf(“terror!!input again:”);

fflush(stdin);

}

fp=fopen(“标记.txt”,“r+”);

fscanf(fp,“%d”,&num);

fclose(fp);

fp=fopen(“记录.txt”,“r+”);

rewind(fp);

initialize(cars,num,fp);

fclose(fp);

j=0;

for(i=1;i<=9*NUM;i++){

if(cars[i].is_in=='y' && cars[i].station_in!=startkey && cars[i].station_out==0)

{

j++;

break;

} } k=0;for(m=1;m<=9*NUM;m++){

if(cars[m].is_in=='n' && cars[m].station_in==0 && cars[m].station_out==startkey)

{

k++;

cars[m].flag=k;

} } if((key==1 && k>0)||(key==2 && j>0)|| key==3 || key==4 || key==5)break;else if(key==2 && j==0){

printf(“t目前尚无车辆要离站!!input again:”);

fflush(stdin);

continue;} else if(key==1 && k==0){

printf(“t目前卡片不足!!input again:”);

fflush(stdin);

continue;} else {

printf(“terror!!input again:”);

fflush(stdin);

continue;} } if(key==1){ system(“cls”);timer=time(NULL);tblock=localtime(&timer);srand((unsigned)time(NULL));//用即时的系统时间来做随机数种子.生成随机数

choice=(rand()%k)+1;//随机生成choice,格式rand()%k即要求产生k以内的

for(m=1;m<=9*NUM;m++)

{

if(cars[m].is_in=='n' && cars[m].station_in==0 && cars[m].station_out==startkey && cars[m].flag==choice)

{

break;

}

}

printf(“卡号是:%dn现在时间是:%sn”,m,mytime(tblock));

cars[m].station_in=startkey;

cars[m].station_out=0;

strcpy(cars[m].time_in,mytime(tblock));

strcpy(cars[m].time_out,“无”);

num=1;

fp=fopen(“标记.txt”,“w+”);

fprintf(fp,“%d”,num);

fclose(fp);

fp=fopen(“记录.txt”,“w+”);

for(i=1;i<=9*NUM;i++)

{

fprintf(fp,“%d %d %c %lf %d %d %st%stn”,cars[i].card_num,cars[i].car_type,cars[i].is_in,cars[i].money,cars[i].station_in,cars[i].station_out,cars[i].time_in,cars[i].time_out);

}

fclose(fp);

printf(“┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓n”);

printf(“┃0.特殊车:军警车、紧急车

┃n”);

printf(“┃1.一类车:小轿车、吉普车、的士头人货车、摩托车

┃n”);

printf(“┃2.二类车:面包车、小型人货车、轻型货车、小型客车

┃n”);

printf(“┃3.三类车:中型客车、大型普通客车、中型货车、大型豪华客车┃n”);

printf(“┃4.四类车: 大型货车、大型拖(挂)车、20英尺集装箱车

┃n”);

printf(“┃5.五类车: 重型货车、重型拖(挂)车、40英尺集装箱车

┃n”);

printf(“┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛n”);

printf(“请选择车型,并输入序号:”);

while(1)

{

fflush(stdin);

while(scanf(“%d%c”,&size,&enter)==0 || enter!='n')

{

printf(“terror!!input again:”);

fflush(stdin);

}

if(size==0 || size==1 || size==2 || size==3 || size==4 || size==5)break;

else

{

printf(“terror!!input again:”);

continue;

}

}

cars[m].is_in='y';

cars[m].car_type=size;

fp=fopen(filename(startkey),“a+”);

fprintf(fp,“%30s%8d%12s%20snn”,mytime(tblock),m,kind[cars[m].car_type],“发卡,放行”);

fclose(fp);

fp=fopen(“标记.txt”,“w+”);

fprintf(fp,“%d”,num);

fclose(fp);

fp=fopen(“记录.txt”,“w+”);

for(i=1;i<=9*NUM;i++)

{

fprintf(fp,“%d %d %c %lf %d %d %st%stn”,cars[i].card_num,cars[i].car_type,cars[i].is_in,cars[i].money,cars[i].station_in,cars[i].station_out,cars[i].time_in,cars[i].time_out);

}

fclose(fp);

printf(“登记完毕,请发卡放行,并按任意键回到主菜单a”);

getche();

}

else if(key==2)

{

system(“cls”);

printf(“请输入卡号(按0返回):”);

while(1)

{

ch='y';

fflush(stdin);

while(scanf(“%d%c”,&choice,&enter)==0 || enter!='n')

{

printf(“terror!!input again:”);

fflush(stdin);

}

fp=fopen(“标记.txt”,“r+”);

fscanf(fp,“%d”,&num);

fclose(fp);

fp=fopen(“记录.txt”,“r+”);

rewind(fp);

initialize(cars,num,fp);

fclose(fp);

if(choice<0 || choice>9*NUM)

{

printf(“无此卡号...ntinput again:”);

continue;

}

else if(choice==0)

{

ch='n';

break;

}

else if(choice>0 && choice<=9*NUM && cars[choice].is_in=='n')

{

printf(“该卡号尚未发布...ntinput again:”);

continue;

}

else if(choice>0 && choice<=9*NUM && cars[choice].is_in=='y' && cars[choice].station_in!=startkey && cars[choice].station_out==0)

{

break;

}

else if(choice>0 && choice<=9*NUM && cars[choice].is_in=='y' && cars[choice].station_in==startkey && cars[choice].station_out==0)

{

printf(“该卡号车于%s从本站进入高速,尚在行...ntinput again:”,cars[choice].time_in);

continue;

}

else

{

printf(“terror!!input again:”);

continue;

}

}

if(ch=='n')continue;

cars[choice].station_out=startkey;

fp=fopen(“记录.txt”,“w+”);

for(i=1;i<=9*NUM;i++)

{

fprintf(fp,“%d %d %c %lf %d %d %st%stn”,cars[i].card_num,cars[i].car_type,cars[i].is_in,cars[i].money,cars[i].station_in,cars[i].station_out,cars[i].time_in,cars[i].time_out);

}

fclose(fp);

if(cars[choice].car_type==0)

{

printf(“该车于%s在%s进入高速,为特殊车,无需收费n”,cars[choice].time_in,address[cars[choice].station_in]);

}

else

{

i=abs(km[cars[choice].station_in]-km[cars[choice].station_out]);

money=cars[choice].money=i*price[cars[choice].car_type];

printf(“该车于%s在%s进入高速,需缴费%.1lf款:”,cars[choice].time_in,address[cars[choice].station_in],cars[choice].money);

fflush(stdin);

while(1)

{

while(scanf(“%lf%c”,&pay,&enter)==0 || enter!='n')

{

printf(“terror!!input again:”);

fflush(stdin);

}

if(pay>money)

{

printf(“缴付%.1lf元,找零%.1lf元...n”,pay,pay-money);

money=0;

break;

}

else if(pay

{

money=money-pay;

printf(“缴付%.1lf元,需再缴付%.1lf元:”,pay,money);

continue;

}

else

{

printf(“已缴费完毕,共收取人民币%.1lf元...n”,cars[choice].money);

break;

}

}

}

timer=time(NULL);

tblock=localtime(&timer);

printf(“现在时间是:%sn”,mytime(tblock));

strcpy(cars[choice].time_out,mytime(tblock));

元,请付

fp=fopen(“档案.txt”,“a+”);

fprintf(fp,“%5d%12s%15s%30s%10.1lf元n”,choice,kind[cars[choice].car_type],address[cars[choice].station_in],cars[choice].time_in,cars[choice].money);

fprintf(fp,“%32s%30snn”,address[cars[choice].station_out],cars[choice].time_out);

fclose(fp);

cars[choice].money=0;

cars[choice].is_in='n';

cars[choice].station_in=0;

cars[choice].station_out=startkey;

strcpy(cars[choice].time_in,“无”);

strcpy(cars[choice].time_out,“无”);

fp=fopen(filename(startkey),“a+”);

if(cars[choice].car_type==0)fprintf(fp,“%30s%8d%12s%20snn”,mytime(tblock),choice,kind[cars[choice].car_type],“收卡,放行”);

else fprintf(fp,“%30s%8d%12s%20snn”,mytime(tblock),choice,kind[cars[choice].car_type],“缴费,收卡,放行”);

fclose(fp);

cars[choice].car_type=0;

fp=fopen(“记录.txt”,“w+”);

for(i=1;i<=9*NUM;i++)

{

fprintf(fp,“%d %d %c %lf %d %d %st%stn”,cars[i].card_num,cars[i].car_type,cars[i].is_in,cars[i].money,cars[i].station_in,cars[i].station_out,cars[i].time_in,cars[i].time_out);

}

fclose(fp);

printf(“请收卡放行,并按任意键回到主菜单a”);

getche();

}

else if(key==3)

{

system(“cls”);

refer(cars,startkey);

}

else if(key==4)

{

while(1)

{

system(“cls”);

printf(“input password: ”);

for(i=0;;)

{

fflush(stdin);

ch=getch();if(ch=='r' || ch=='n')

{

break;} else if(ch=='b'){

if(i-->0)

{

pwd[i]='';

printf(“b b”);

//删除前个字符,光标退一个

}

continue;}

else if(i==max_len)

{

continue;}

else

{

pwd[i++]=ch;

//接收字符到密码中

printf(“*”);} } pwd[i]='';fp=fopen(“password.txt”,“a+”);rewind(fp);fscanf(fp,“%8s”,password);fclose(fp);if(strcmp(pwd,password)==0){ break;} else { printf(“n密码错误或空密码!!(空密码时系统规定为不能注销)n”);printf(“想再输一遍密码吗?(y or n):”);while(1){

fflush(stdin);

ch=getche();

if(ch=='y' || ch=='Y')

{

system(“cls”);

break;

}

else if(ch=='n' || ch=='N')

{

break;

}

else

{

printf(“b b”);

continue;

}

}

if(ch=='y' || ch=='Y')continue;

else if(ch=='n' || ch=='N')break;

}

}

if(ch=='n' || ch=='N')continue;

i=0;

for(j=1;j<=9;j++)

{

fp=fopen(filename(j),“w+”);

fclose(fp);

}

fp=fopen(“记录.txt”,“w+”);

fclose(fp);

fp=fopen(“标记.txt”,“w+”);

fprintf(fp,“%dn”,i);

fclose(fp);

fp=fopen(“档案.txt”,“w+”);

fclose(fp);

printf(“n注销成功!!n”);

break;

}

else

{

fp=fopen(“记录.txt”,“w+”);

for(i=1;i

{

fprintf(fp,“%d %d %c %lf %d %d %st%stn”,cars[i].card_num,cars[i].car_type,cars[i].is_in,cars[i].money,cars[i].station_in,cars[i].station_out,cars[i].time_in,cars[i].time_out);

}

fclose(fp);

fp=fopen(“标记.txt”,“w+”);

fprintf(fp,“%dn”,num);

fclose(fp);

break;

} } return 0;} char *mytime(struct tm *timeptr)

//获取系统时间的函数 { char wday_name[7][4]={“Sun”,“Mon”,“Tue”,“Wed”,“Thu”,“Fri”,“Sat”};static char result[29];sprintf(result,“%d年%d月%d日(%3s)%d:%d:%d”,1900+timeptr->tm_year,1+timeptr->tm_mon,timeptr->tm_mday,wday_name[timeptr->tm_wday],timeptr->tm_hour,timeptr->tm_min, timeptr->tm_sec);return result;} char *filename(int startkey){ static char name[22];sprintf(name,“车辆处理与记录%d.txt”,startkey);return name;}

void Delay(int n)//延时函数 { int i,j,k;for(i=1;i<=n;i++){

for(j=1;j<500;j++)

{

for(k=1;k<500;k++)

{

}

} } }

void initialize(struct car *cars,int num,FILE *fp)///初始化函数 { int i,j;if(num==0){

for(j=1;j<=9;j++)

{

for(i=NUM*(j-1)+1;i

{

cars[i].money=0;

cars[i].card_num=i;

cars[i].is_in='n';

cars[i].car_type=0;

cars[i].station_in=0;

cars[i].station_out=j;

strcpy(cars[i].time_in,“无”);

strcpy(cars[i].time_out,“无”);

}

} } else {

for(i=1;i<=9*NUM;i++)

{

fscanf(fp,“%d %d %c %lf %d %d %st%stn”,&cars[i].card_num,&cars[i].car_type,&cars[i].is_in,&cars[i].money,&cars[i].station_in,&cars[i].station_out,cars[i].time_in,cars[i].time_out);

} } } int refer(struct car *cars,int startkey)//查询 { FILE *fp;int i,j,key,num,k;char ch,enter;time_t timer;struct tm *tblock;

while(1){

system(“cls”);

printf(“┏━━━━━━━━━━━━━━━━━━━━┓n”);

printf(“┃

****资料查询****

┃n”);

printf(“┃

1.里程价

┃n”);

printf(“┃

2.汽车类型

┃n”);

printf(“┃

3.沿线站点间里程

┃n”);

printf(“┃

4.高速通车情况

┃n”);

printf(“┃

5.道路交通安全法实施条例

┃n”);printf(“┃

6.车辆处理与记录

┃n”);printf(“┃

0.回到主菜单

┃n”);printf(“┗━━━━━━━━━━━━━━━━━━━━┛n”);printf(“请选择,并输入序号:”);while(1){ fflush(stdin);while(scanf(“%d%c”,&key,&enter)==0 || enter!='n'){

printf(“terror!!input again:”);

fflush(stdin);}

if(key==1 || key==2 || key==3 || key==4 || key==5 || key==6 || key==0){

system(“cls”);

switch(key)

{

case 1:

{

printf(“t里程价n”);

for(i=1;i<6;i++)

{

printf(“%s:%.1lf元/公里n”,kind[i],price[i]);

}

printf(“nt按任意键回到查询菜单”);

fflush(stdin);

getche();

break;

}

case 2:

{

printf(“t汽车类型n”);

printf(“一类车:小轿车、吉普车、的士头人货车、摩托车n”);

printf(“二类车:面包车、小型人货车、轻型货车、小型客车n”);

printf(“三类车:中型客车、大型普通客车、中型货车、大型豪华客车n”);

printf(“四类车: 大型货车、大型拖(挂)车、20英尺集装箱车n”);

printf(“五类车: 重型货车、重型拖(挂)车、40英尺集装箱车n”);

printf(“nt按任意键回到查询菜单”);

fflush(stdin);

getche();

break;

}

case 3:

{

printf(“t沿线站点间里程n”);printf(“┏━━━━━━━━━━━━━━━━━━━━┓n”);printf(“┃

1.湛江

2.茂名

3.阳江

┃n”);printf(“┃

4.开平

5.佛山

6.广州

┃n”);printf(“┃

7.深圳

8.汕头

9.汾水关

┃n”);printf(“┗━━━━━━━━━━━━━━━━━━━━┛n”);printf(“请选择起始站,并输入序号:”);fflush(stdin);while(1){ while(scanf(“%d%c”,&i,&enter)==0 || enter!='n'){

printf(“terror!!input again:”);

fflush(stdin);} if(i==1 || i==2 || i==3 || i==4 || i==5 || i==6 || i==7 || i==8 || i==9)break;else

{

printf(“terror!!input again:”);

continue;} } printf(“请选择终点站,并输入序号:”);fflush(stdin);while(1){ while(scanf(“%d%c”,&j,&enter)==0 || enter!='n'){

printf(“terror!!input again:”);

fflush(stdin);} if(j==1 || j==2 || j==3 || j==4 || j==5 || j==6 || j==7 || j==8 || j==9)break;else

{

printf(“terror!!input again:”);

continue;} } printf(“tt里程为:%d公里.n”,abs(km[i]-km[j]));printf(“nt按任意键回到查询菜单”);fflush(stdin);getche();break;

“);

} case 4: {

fp=fopen(”标记.txt“,”r+“);

fscanf(fp,”%d“,&num);

fclose(fp);

fp=fopen(”记录.txt“,”r+“);

rewind(fp);

initialize(cars,num,fp);

fclose(fp);

j=0;

k=0;

for(i=1;i<=9*NUM;i++)

{

if(cars[i].station_in!=0 && cars[i].station_out==0)j++;

if(cars[i].station_in!=0 && cars[i].station_out!=0)k++;

}

timer=time(NULL);

tblock=localtime(&timer);

printf(”现在时间是:%sn“,mytime(tblock));

printf(”在行车辆:共%d辆.n“,j);

if(k>0)printf(”t且有%d辆车正在缴费处缴费,尚未离开.nn“,k);

printf(”t以下为此高速公路通车情况.nnnn“);

printf(”%5s%12s%15s%30s%10sn“,”卡号“,”车型“,”进/出站点“,”进/出时间“,”金额

fp=fopen(“档案.txt”,“a+”);

rewind(fp);

fflush(stdin);

while(feof(fp)==0)

{

fflush(stdin);

ch=fgetc(fp);

putch(ch);

}

fclose(fp);

printf(“t按任意键回到查询菜单”);

fflush(stdin);

getche();

break;} case 5: {

fp=fopen(“广东省道路交通安全法实施条例.txt”,“a+”);printf(“t广东省道路交通安全法实施条例n”);

} case 6: {

} case 0: rewind(fp);fflush(stdin);while(1){ for(i=0;(i<4000 && feof(fp)==0)||(i>=4000 && ch!='n' && feof(fp)==0);i++){

fflush(stdin);

ch=fgetc(fp);

putch(ch);} if(feof(fp)==0){

printf(“nnt按任意键翻到下一页”);

getche();

system(“cls”);

continue;} else break;} fclose(fp);printf(“t按任意键回到查询菜单”);fflush(stdin);getche();break;

printf(“%30s%8s%12s%20sn”,“时间”,“卡号”,“车型”,“处理情况”);fp=fopen(filename(startkey),“a+”);rewind(fp);fflush(stdin);while(feof(fp)==0){ fflush(stdin);ch=fgetc(fp);putch(ch);} fclose(fp);printf(“t按任意键回到查询菜单”);fflush(stdin);getche();break;

} } }

{

return 0;

break;

} } } else { printf(“terror!!input again:”);continue;} if(key==1 || key==2 || key==3 || key==4 || key==5 || key==6)break;

下载校运动会管理系统报告C语言(含完整代码)word格式文档
下载校运动会管理系统报告C语言(含完整代码).doc
将本文档下载到自己电脑,方便修改和收藏,请勿使用迅雷等下载。
点此处下载文档

文档为doc格式


声明:本文内容由互联网用户自发贡献自行上传,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任。如果您发现有涉嫌版权的内容,欢迎发送邮件至:645879355@qq.com 进行举报,并提供相关证据,工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。

相关范文推荐

    图书管理系统(含源代码)c语言_数据结构课程设计报告

    数据结构大作业 121279044 伍杨 数据结构大作业 图书管理系统 工程管理 121279044 伍杨 目录 一、 二、 三、 题目要求 .......................................................

    c语言课程设计-学籍管理系统(含源代码)

    课 程 设 计 课程设计名称: C语言程序设计 题 目:学籍管理系统 学 生 姓 名: 学生学号 : 学 院(系): 软件学院 专 业 班 级: 112021 指 导 教 师: 设计时间: 2012 年 9 月 日......

    c语言课程设计运动会比赛计分系统(含任务书)

    一、 课程设计目的 将理论教学中涉及到的知识点贯穿起来,对不同的数据类型、程序控制结构、数据结构作一比较和总结,结合设计题目进行综合性应用,对所学知识达到融会贯通的程度......

    c语言实习报告 停车场管理系统

    C语言课程设计 院系:工程学院 姓名:姚 品 品 学号:20051001635 班号:05205224 指导教师:王老师 日期:2007年9月 一课程设计编号、名称、内容 编号:第二十七题 名称:停车场管理系统2......

    C语言药房管理系统

    #include #include #include #include struct medicine { char name[20]; //药品名称 char number[50]; //药品编号 char price[50]; //单价 char inventory[50]; //库存......

    c语言 电话簿管理系统

    #include "stdio.h" #include "string.h" #define N 20 struct mem { char name[20]; char tel[20]; char wu[20]; char dz[20]; }mem[N]; void sorttel(struct mem tel[])......

    c语言图书管理系统

    C语言——图书管理系统 代码部分: #include #include #include #pragma comment(lib,"libmysql.lib") /*定义数据库相关操作变量*/ MYSQL mysql; // MYSQL_RES *result......

    C语言-通讯录管理系统

    #include #include #include struct record{ charnum[12]; char name[10]; char birthday[10]; char post[10]; char phone[15]; }data[100]; intmenu_select( ); intcreat......