From 7c469a54f647dd5e8c0fad64d0b92fb82cb86db5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E4=B8=81?= <18408000217@stu.hut.edu.cn> Date: Thu, 10 Jan 2019 20:07:41 +0800 Subject: [PATCH] first commit --- 高论域提交的.c | 415 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 415 insertions(+) create mode 100644 高论域提交的.c diff --git a/高论域提交的.c b/高论域提交的.c new file mode 100644 index 0000000..1aaf0bb --- /dev/null +++ b/高论域提交的.c @@ -0,0 +1,415 @@ +#include +#include +#include +#include +int i=1; +struct staffsinfor +{ + char staffnums[100]; + char name[100]; + char sex[100]; + char year[100]; + char studyF[100]; + char homedress[100]; + char money[100]; + char phonenum[100]; +}staffs[50]; +void reader() +{ + FILE *fp; + int n = 0; + if( (fp = fopen("g:\\..txt","r")) == NULL ) + { + + return 0; + } + fscanf(fp,"%d\n",&i); + while(n < i) + { + fscanf(fp,"%s\n%s\n%s\n%s\n%s\n%s\n%s\n",staffs[n].staffnums,staffs[n].name,staffs[n].sex,staffs[n].studyF,staffs[n].homedress,staffs[n].money,staffs[n].phonenum); + n ++; + } + + + fclose(fp); +} +void writeer() +{ + FILE *fp; + int n = 0; + if( (fp = fopen("g:\\..txt","wb")) == NULL ) + { + return ; + } + fprintf(fp,"%d\n",i); + while(n < i) + { + fprintf(fp,"%s\n%s\n%s\n%s\n%s\n%s\n%s\n",staffs[n].staffnums,staffs[n].name,staffs[n].sex,staffs[n].studyF,staffs[n].homedress,staffs[n].money,staffs[n].phonenum); + n ++; + } + fclose(fp); +} +void input(struct staffsinfor staffs[]){ + + + int n; + int a; + int c,d; + reader(); + system("cls"); + do + { + system("cls"); + printf("\t\t\t\tڽеϢ¼룡\t\t\t\n\n\n"); + a = 0; + printf("\t\tְĹ: \n\t\t"); + scanf("%s",staffs[i].staffnums); + for(n = 0 ; n < i ; n ++) + { + if(strcmp(staffs[n].staffnums,staffs[i].staffnums) == 0) + { + a = 1; + break; + } + } + if(a!=0) + { + + MessageBox(NULL,"ְѴ","ϵͳʾ",MB_OK); + d= MessageBox(NULL,"Ƿ","ϵͳʾ",MB_YESNO); + if(d==6) + continue; + break; + } + printf("\t\tְ: \n\t\t"); + scanf("%s",staffs[i].name); + printf("\t\tְԱ: \n\t\t"); + scanf("%s",staffs[i].sex); + printf("\t\tְ: \n\t\t"); + scanf("%s",staffs[i].year); + printf("\t\tְѧ: \n\t\t"); + scanf("%s",staffs[i].studyF); + printf("\t\tְĹ: \n\t\t"); + scanf("%s",staffs[i].money); + printf("\t\tְסַ: \n\t\t"); + scanf("%s",staffs[i].homedress); + printf("\t\tְĵ绰: \n\t\t"); + scanf("%s",staffs[i].phonenum); + c=MessageBox(NULL,"Ƿ","ϵͳʾ",MB_YESNO); + i ++; + }while( c ==6); + writeer(); + MessageBox(NULL,"","ϵͳʾ",MB_OK); +} + +void look(struct staffsinfor staffs[]){ + int j;;char o; + reader();j=i-1; + three : + system("cls"); + printf("\t\t\t\tڽе\n\n\n"); + if(j==0) + { + MessageBox(NULL,"δҵϢ","ϵͳʾ",MB_OK); + return 0; + } + + + system("cls"); + printf("\t\t\t\n\t\t\t\t\t\t\t%s",staffs[j].name); + printf("\n\t\t\tְţ\n\t\t\t\t\t\t\t%s",staffs[j].staffnums); + printf("\n\t\t\tԱ\n\t\t\t\t\t\t\t%s",staffs[j].sex); + printf("\n\t\t\t䣺\n\t\t\t\t\t\t\t%s",staffs[j].year); + printf("\n\t\t\tѧ\n\t\t\t\t\t\t\t%s",staffs[j].studyF); + printf("\n\t\t\tʣ\n\t\t\t\t\t\t\t%s",staffs[j].money); + printf("\n\t\t\tͥסַ\n\t\t\t\t\t\t\t%s",staffs[j].homedress); + printf("\n\t\t\t绰룺\n\t\t\t\t\t\t\t%s",staffs[j].phonenum); + printf("\n\n\n\t\t\t\t\t\tADл\n\t\t\t\t\t\tBackSpace˻ز˵"); + o=getch(); + if(o=='A') + { + if(j==1) + {system("cls"); + printf("Ѿǵһ"); + system("pause"); + goto three; + } + j--; + goto three; + } + if(o=='D') + { + if(j==i&&j!=i) + {system("cls"); + printf("һ"); + system("pause"); + goto three; + } + j++; + goto three; + } + if(o==8) + return 0; + + + +} +void output_inf(int id) +{ + printf("\t\t : %s\n",staffs[id].name); + printf("\t\t : %s\n",staffs[id].staffnums); + printf("\t\t Ա: %s\n",staffs[id].sex); + printf("\t\t : %s\n",staffs[id].year); + printf("\t\t ѧ: %s\n",staffs[id].studyF); + printf("\t\t : %s\n",staffs[id].money); + printf("\t\t סַ: %s\n",staffs[id].homedress); + printf("\t\t 绰: %s\n",staffs[id].phonenum); + printf("\n\n\n"); +} +void shanchu(){ + int n,j;char delete_ID[20]; + int flag; + char c; + reader(); + while(1) + { + system("cls"); + flag = 0; + printf("ɾְϢĹţ"); + scanf("%s",delete_ID); + for(n=0;n 2) + { + printf("ָ\n\n"); + system("pause"); + continue; + } + system("cls"); + flag = 0;//ְϢǷ + if(num == 1)//Ųѯ + { + printf("\t\tҪѯְĹţ"); + scanf("%s",q_id); + for(n = 0 ; n < i ;n ++) + { + if( strcmp(staffs[n].staffnums,q_id) == 0) + { + output_inf(n); + flag = 1;// + break; + } + } + } + else if(num == 2)//ѯ + { + printf("\t\tҪѯְ"); + scanf("%s",q_name); + for(n = 0 ; n < i ;n ++) + { + if( strcmp(staffs[n].name,q_name) == 0) + { + output_inf(n); + flag = 1;// + } + } + } + else if(num ==0) + return 0; + + if(!flag)//жǷиְϢ + { + printf("\n\n޸ְϢ!\n\n"); + } + int k; + k= MessageBox(NULL,"Ƿ","ϵͳʾ",MB_YESNO); + if(k!=6) break; + } +} + +void xiugai(){ + char change_ID[20];//޸ĵְĹ + int number;//ְϢеλ + char num;//ָ + char message[100];//޸ĵϢ + char c;//ָY?N + int flag; + int n; + reader(); + while(1) + { + flag = 0; + system("cls"); + printf("޸ĵְĹţ"); + scanf("%s",change_ID); + for(n = 0 ; n < i ; n ++) + { + if( strcmp(staffs[n].staffnums,change_ID) == 0 ) + { + number = n; + flag = 1; + break; + } + } + if(!flag) + { + printf("\n\n޴ԱϢ\n\n"); + c=MessageBox(NULL,"Ƿ","ϵͳʾ",MB_YESNO); + if(c==6) continue; + break; + } + printf("\n\n\t\t******************޸********************\n"); + printf("\t\t* *\n"); + printf("\t\t* 1.޸ *\n"); + printf("\t\t* *\n"); + printf("\t\t* 2.޸ѧ *\n"); + printf("\t\t* *\n"); + printf("\t\t* 3.޸Ĺ *\n"); + printf("\t\t* *\n"); + printf("\t\t* 4.޸סַ *\n"); + printf("\t\t* *\n"); + printf("\t\t* 5.޸ĵ绰 *\n"); + printf("\t\t* *\n"); + printf("\t\t* 6.޸Ա *\n"); + printf("\t\t* *\n"); + printf("\t\t* 0˳ *\n"); + printf("\t\t******************************************\n"); + printf("\t\tָ(1-6):"); + scanf("%*c%c",&num); + if(num < '1' || num > '6') + { + printf("ָ\n\n"); + system("pause"); + continue; + } + system("cls"); + printf("޸ĺϢ"); + scanf("%s",message); + switch(num) + { + case '1' : strcpy(staffs[number].name,message); break; + case '2' : strcpy(staffs[number].studyF,message); break; + case '3' : strcpy(staffs[number].money,message); break; + case '4' : strcpy(staffs[number].homedress,message); break; + case '5' : strcpy(staffs[number].phonenum,message); break; + case '6' : strcpy(staffs[number].sex,message);break; + case '0' :exit(1); + } + system("cls");int k; + k=MessageBox(NULL,"Ƿ","ϵͳʾ",MB_YESNO); + + if(k==6) break; + } + writeer(); +} + +int main() +{ + char a; + /*ְϢϵͳƣ2ˣ +ְϢְšԱ䡢ѧʡסַ绰ȣְŲظ +һְϢϵͳʹ֮ṩ¹ܣ +1ϵͳԲ˵ʽ +2ְϢ¼빦(ְϢļ) +3ְϢܣ +4ְϢѯܣ㷨 +ѯʽ +ѧѯ +ְŲѯ +5ְϢɾ޸Ĺ(ѡ)*/ + + one : + system("cls"); + printf("\t\t\t\t˵\t\t\t\t\n"); + printf("**********************************************************************\n\n\n"); + printf("\t\t\t\tA.¼Ϣ\t\t\t\t\n\n"); + printf("\t\t\t\tB.\t\t\t\t\n\n"); + printf("\t\t\t\tC.ѯϢ\t\t\t\t\n\n"); + printf("\t\t\t\tD.ɾϢ\t\t\t\t\n\n"); + printf("\t\t\t\tE.޸Ϣ\t\t\t\t\n\n"); + printf("\t\t\t\t\tBackSpaceһҳ\n\n\n"); + printf("\t\t\t\t\tBy--޶\n\n"); + printf("**********************************************************************\n"); + a=getch(); + if(a=='A') + { + input(staffs); + goto one; + } + else if(a=='B') + { + look(staffs); + goto one; + } + else if(a=='C') + { + que(staffs); + + + goto one; + } + else if(a=='D') + { + shanchu(); + goto one; + } + else if(a=='E') + { + xiugai(); + goto one; + } + else + { + printf("!"); + system("pause"); + goto one; + } + return 0; + +} + + +