版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
VC++综合试验图书馆管理系统.txt都是一种山旳狐狸,你跟我讲什么聊斋,站在离你近来旳地方,眺望你对他人旳微笑,虽然心是百般旳疼痛 只为把你旳一举一动尽收眼底.耀眼旳白色,让我明白什么是纯粹旳伤害。#include<stdio.h>#include<stdlib.h>#include<string.h>#defineLENGTH20#defineSUBJECT10charsubcall[SUBJECT][LENGTH];intnum_of_stu=0;intnum_of_sub=0;structdata{ charname[LENGTH]; charnum[LENGTH]; floatscore[SUBJECT]; floatsum; floataver; structdata*next;};voidMenu(void);structdata*Append(structdata*);voidCheck(structdata*);voidModify(structdata*);voidList(structdata*);voidSearch(structdata*);structdata*Delete(structdata*);structdata*Sort1(structdata*,int(*g)(float,float));voidSort2(structdata*,int(*g)(float,float));intdescend(float,float);intascend(float,float);voidmain(){ Menu();}voidMenu(void){ char*choice[9]={"1.Appendrecord","2.Checkrecord","3.Modifyrecord","4.Listrecord","5.Searchrecord","6.Deleterecord","7.Sortscoreindescendingorder","8.Sortscoreinascendingorder","0.exit"}; structdata*head=NULL; charreply,c; intn=0,k,i; for(i=0;i<9;i++) { k=strlen(choice[i]); n=(n>k)?n:k; } while(1) { system("cls"); printf("\t\tWelcometotheStudents'ScoreManagementSystem\n"); printf("\t\t\t-----------------------------------\n"); for(i=0;i<9;i++) { printf("\t\t\t|%s",choice[i]); k=strlen(choice[i]); for(;n-k>0;k++) putchar(''); printf("|\n"); } printf("\t\t\t-----------------------------------\n"); while(1) { printf("Pleaseinputyourchoice:"); reply=getchar(); if(reply=='\n') continue; else c=getchar(); if(reply>='0'&&reply<='8'&&c=='\n') break; elseif(c!='\n') while(c=getchar()!='\n'); printf("Thereisnosuchchoice!\n"); } if(reply>'1'&&head==NULL) printf("Thereisnodatastored!\n"); else { switch(reply) { case'1':head=Append(head);break; case'2':Check(head);break; case'3':Modify(head);break; case'4':List(head);break; case'5':Search(head);break; case'6':head=Delete(head);break; case'7':Sort2(head,descend);break; case'8':Sort2(head,ascend);break; default:while(1) { printf("Doyoureallywanttoexit(Y/Nory/n)?"); reply=getchar(); if(reply=='\n') continue; else c=getchar(); if((reply=='Y'||reply=='N'||reply=='y'||reply=='n')&&c=='\n') break; elseif(c!='\n') while(c=getchar()!='\n'); } if(reply=='Y'||reply=='y') { free(head); return; } } } while(1) { printf("PressENTERtocontinue:"); scanf("%c",&reply); if(reply=='\n') break; else while(c=getchar()!='\n'); } }}structdata*Append(structdata*head){ structdata*p; charreply,c; inti; system("cls"); if(head==NULL) { p=head=(structdata*)malloc(sizeof(structdata)); printf("Howmanysubjectsdoyouwanttorecord(n<=%d)?",SUBJECT); scanf("%d%*c",&num_of_sub); for(i=0;i<num_of_sub;i++) { printf("Pleaseinputsubject%d'sname:",i+1); scanf("%s%*c",subcall[i]); } } else { for(p=head;p->next!=NULL;p=p->next); p->next=(structdata*)malloc(sizeof(structdata)); p=p->next; }loop:printf("Pleaseinputthestudent'sname:"); scanf("%s%*c",p->name); printf("Pleaseinputthestudent'snumber:"); scanf("%s%*c",p->num); p->sum=0; for(i=0;i<num_of_sub;i++) { printf("Pleaseinputthestudent's%sscore:",subcall[i]); scanf("%f%*c",&p->score[i]); p->sum+=p->score[i]; } p->aver=p->sum/num_of_sub; num_of_stu++; while(1) {printf("Doyouwanttogoonappending(Y/Nory/n)?"); reply=getchar(); if(reply=='\n') continue; else c=getchar(); if((reply=='Y'||reply=='N'||reply=='y'||reply=='n')&&c=='\n') break; elseif(c!='\n') while(c=getchar()!='\n'); } if(reply=='Y'||reply=='y') { p->next=(structdata*)malloc(sizeof(structdata)); p=p->next; gotoloop; } else { p->next=NULL; returnhead; }}voidCheck(structdata*head){ structdata*p,*q; structdata**t=(structdata**)malloc(num_of_stu/2*sizeof(structdata*)); intminlim,maxlim,n=0,i; system("cls"); for(p=head;p!=NULL;p=p->next) { for(i=0;i<n;i++) { if(strcmp(p->name,(*(t+i))->name)==0) break; } if(i<n) continue; for(q=p->next;q!=NULL;q=q->next) { if(strcmp(p->name,q->name)==0) { printf("Name%shasbeeninputedrepeatedly!\n",p->name); *(t+n)=p; n++; break; } } } printf("Altogether%dnamehasbeenrepeatedlyinputed.\n",n); n=0; for(p=head;p!=NULL;p=p->next) { for(i=0;i<n;i++) { if(strcmp(p->num,(*(t+i))->num)==0) break; } if(i<n) continue; for(q=p->next;q!=NULL;q=q->next) { if(strcmp(p->num,q->num)==0) { printf("Student'snumber%shasbeeninputedrepeatedly!\n",p->num); *(t+n)=p; n++; break; } } } printf("Altogether%dnumberhasbeenrepeatedlyinputed.\n",n); free(t); n=0; printf("Nowcheckdata\n"); printf("Pleaseinputtheminimumlimit:"); scanf("%d%*c",&minlim); printf("Pleaseinputthemaximumlimit:"); scanf("%d%*c",&maxlim); if(maxlim<minlim) { printf("Inputerror!\n"); return; } for(p=head;p!=NULL;p=p->next) { for(i=0;i<num_of_sub;i++) { if(p->score[i]<minlim||p->score[i]>maxlim) { if(!n) printf("Thesedatahasbeenwronglyinputed:\n"); printf("%s's%sscore.\n",p->name,subcall[i]); n++; } } } printf("Altogether%dwrongdata.\n",n);}voidModify(structdata*head){ structdata*p; charmodname[LENGTH],modscore[LENGTH]; charreply,c; inti; system("cls"); do { printf("Pleaseinputthenameofthestudentwhosedatayouwanttomodify:"); scanf("%s%*c",modname); for(p=head;p!=NULL&&strcmp(p->name,modname)!=0;p=p->next); if(p==NULL) printf("Thestudentdoesn'texist!\n"); else { printf("Successfullyfound!\n"); while(1) {printf("Doyouwanttomodifythestudent'snumber(Y/Nory/n)?"); reply=getchar(); if(reply=='\n') continue; else c=getchar(); if((reply=='Y'||reply=='N'||reply=='y'||reply=='n')&&c=='\n') break; elseif(c!='\n') while(c=getchar()!='\n'); } if(reply=='Y'||reply=='y') { printf("Pleaseinputthestudent'snewnumber:"); scanf("%s%*c",p->num); } while(1) {printf("Doyouwanttomodifythestudent'sscore(Y/Nory/n)?"); reply=getchar(); if(reply=='\n') continue; else c=getchar(); if((reply=='Y'||reply=='N'||reply=='y'||reply=='n')&&c=='\n') break; elseif(c!='\n') while(c=getchar()!='\n'); } if(reply=='Y'||reply=='y') { do { printf("Pleaseinputthenameofthesubjectwhosescoreyouwanttomodify:"); scanf("%s%*c",modscore); for(i=0;i<num_of_sub;i++) { if(strcmp(subcall[i],modscore)==0) { p->sum-=p->score[i]; printf("Pleaseinput%s'snew%sscore:",p->name,modscore); scanf("%f%*c",&p->score[i]); p->sum+=p->score[i]; break; } } if(i==num_of_sub) printf("Thesubjectdoesn'texist!\n"); while(1) {printf("Doyouwanttogoonmodifyingthestudent'sotherscoresofsubject(Y/Nory/n)?"); reply=getchar(); if(reply=='\n') continue; else c=getchar(); if((reply=='Y'||reply=='N'||reply=='y'||reply=='n')&&c=='\n') break; elseif(c!='\n') while(c=getchar()!='\n'); } } while(reply=='Y'||reply=='y'); p->aver=p->sum/num_of_sub; } } while(1) {printf("Doyouwanttogoonmodifyingotherstudents'data(Y/Nory/n)?"); reply=getchar(); if(reply=='\n') continue; else c=getchar(); if((reply=='Y'||reply=='N'||reply=='y'||reply=='n')&&c=='\n') break; elseif(c!='\n') while(c=getchar()!='\n'); } } while(reply=='Y'||reply=='y');}voidList(structdata*head){ structdata*p; intn1=0,n2=0,k,i; system("cls"); printf("name"); for(p=head;p!=NULL;p=p->next) { k=strlen(p->name); n1=(n1>k)?n1:k; } n1=(n1>4)?n1:4; for(i=0;i<n1-4;i++) putchar(''); printf("number"); for(p=head;p!=NULL;p=p->next) { k=strlen(p->num); n2=(n2>k)?n2:k; } n2=(n2>6)?n2:6; for(i=0;i<n2-6;i++) putchar(''); for(i=0;i<num_of_sub;i++) printf("%s",subcall[i]); if(num_of_sub>0) printf("sumaver"); putchar('\n'); for(p=head;p!=NULL;p=p->next) { printf("%s",p->name); k=strlen(p->name); for(i=0;i<n1-k;i++) putchar(''); printf("%s",p->num); k=strlen(p->num); for(i=0;i<n2-k;i++) putchar(''); for(i=0;i<num_of_sub;i++) { printf("%.1f",p->score[i]); k=strlen(subcall[i]); for(;k-4>0;k--) putchar(''); } if(num_of_sub>0) printf("%.2f%.2f",p->sum,p->aver); putchar('\n'); } printf("Altogether%drecords.\n",num_of_stu);}voidSearch(structdata*head){ structdata*p; charfindname[LENGTH]={'\0'}; charfindnum[LENGTH]={'\0'}; charreply,c; intflag,n1,n2,k,i; system("cls"); do { printf("Doyouwanttosearchthestudentbyname(enter1)orbynumber(enter2)?"); scanf("%d%*c",&flag); } while(flag!=1&&flag!=2); do { if(flag==1) { printf("Pleaseinputthenameofthestudentyouarefinding:"); scanf("%s%*c",findname); } else { printf("Pleaseinputthenumberofthestudentyouarefinding:"); scanf("%s%*c",findnum); } for(p=head;p!=NULL;p=p->next) { if(strcmp(p->name,findname)==0||strcmp(p->num,findnum)==0) { printf("successfullyfound:\nname"); n1=strlen(p->name); n1=(n1>4)?n1:4; for(i=0;i<n1-4;i++) putchar(''); printf("number"); n2=strlen(p->num); n2=(n2>6)?n2:6; for(i=0;i<n2-6;i++) putchar(''); for(i=0;i<num_of_sub;i++) printf("%s",subcall[i]); if(num_of_sub>0) printf("sumaver"); putchar('\n'); printf("%s",p->name); k=strlen(p->name); for(i=0;i<n1-k;i++) putchar(''); printf("%s",p->num); k=strlen(p->num); for(i=0;i<n2-k;i++) putchar(''); for(i=0;i<num_of_sub;i++) { printf("%.1f",p->score[i]); k=strlen(subcall[i]); for(;k-4>0;k--) putchar(''); } if(num_of_sub>0) printf("%.2f%.2f",p->sum,p->aver); putchar('\n'); break; } } if(p==NULL) printf("Thestudentdoesn'texist!\n"); while(1) {printf("Doyouwanttogoonsearching(Y/Nory/n)?"); reply=getchar(); if(reply=='\n') continue; else c=getchar(); if((reply=='Y'||reply=='N'||reply=='y'||reply=='n')&&c=='\n') break; elseif(c!='\n') while(c=getchar()!='\n'); } } while(reply=='Y'||reply=='y');}structdata*Delete(structdata*head){ structdata*p,*q; chardelname[LENGTH]={'\0'}; chardelnum[LENGTH]={'\0'}; charreply,c; intflag; system("cls"); do { printf("Doyouwanttodeleteallthedata(enter1)orjustonestudent'sdata(enter2)?"); scanf("%d%*c",&flag); } while(flag!=1&&flag!=2); if(flag==1) { num_of_stu=0; free(head); printf("Successfullydeleted!\n"); returnNULL; } else { do { printf("Doyouwanttodeletethedatabyname(enter1)orbynumber(enter2)?"); scanf("%d%*c",&flag); } while(flag!=1&&flag!=2); do { if(flag==1) { printf("Pleaseinputthenameofthestudentwhosedatayouwanttodelete:"); scanf("%s%*c",delname); } else { printf("Pleaseinputthenumberofthestudentwhosedatayouwanttodelete:"); scanf("%s%*c",delnum); } for(p=head;p!=NULL;q=p,p=p->next) { if(strcmp(p->name,delname)==0||strcmp(p->num,delnum)==0) { if(p==head) head=p->next; else q->next=p->next; num_of_stu--; free(p); printf("Successfullydeleted!\n"); break; } } if(p==NULL) printf("Thestudentdoesn'texist!\n"); if(num_of_stu==0) reply='N'; else { while(1) {printf("Doyouwanttogoondeleting(Y/Nory/n)?"); reply=getchar(); if(reply=='\n') continue; else c=getchar(); if((reply=='Y'||reply=='N'||reply=='y'||reply=='n')&&c=='\n') break; elseif(c!='\n') while(c=getchar()!='\n'); } } } while(reply=='Y'||reply=='y'); returnhead; }}structdata*Sort1(structdata*head,int(*g)(float,float)){ structdata*p,*q,*t,*pf=NULL,*qf=NULL,*tf=NULL,*temp; system("cls"); for(p=head;p!=NULL;pf=t,p=t->next) { t=p; for(q=p->next;q!=NULL;qf=q,q=q->next) { if((*g)(q->sum,t->sum)) { t=q; tf=qf; } } if(t!=p) { if(p==head) head=t; else pf->next=t; if(t==p->next) { p->next=t->next; t->next=p; } else { temp=p->next; p->next=t->next; t->next=temp; tf->next=p; } } } List(head); returnhead;}voidSort2(structdata*head,int(*g)(float,float)){ structdata**queue=(structdata**)malloc(num_of_stu*sizeof(structdata*)); structdata*p,*t; intn1=0,n2=0,k,i,j; sy
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025版高考物理二轮复习 第18讲 光学和热学实验
- 山东省武城县三校联考2024-2025学年度第一学期第二次月考七年级历史试题
- 2024-2025学年度上学期九年级十二月联考英语试卷
- 圆明园湖底防渗事件案例分析
- 5.2 桥式整流教学课件
- 高一(纲要上)统编版 历史 第一单元《第一单元复习 从中华文明起源到秦汉统一多民族封建国家的建立与巩固》课件
- 2025年中考英语一轮教材复习 写作话题7 兴趣爱好
- 2025年中考英语一轮教材复习 七年级(下) Unit 6-2
- 包装制品生产加工项目可行性研究报告写作模板-拿地备案
- 中国红军城保护性改造项目可研报告
- 2024年政府采购评审专家考试题库含答案
- 9.关于工程款迟延支付影响工期的函
- 部编本语文七年级上册单元字词检测题
- 重大件货物运输
- 采煤工作面瓦斯抽放设计方案doc
- 河北专接本公共英语PPT课件
- 高效课堂和有效教学模式研究课题中期报告
- 抗浮桩施工工艺及方法
- 《肉鸡生产性能测定技术规范》(公开征求意见稿)标准文本
- 外加剂检测知识培训讲义ppt课件
- 皮肤科疾病临床评分表
评论
0/150
提交评论