diff --git a/2209040027/Design of Student Adress Book Management System/README.md b/2209040027/Design of Student Adress Book Management System/README.md new file mode 100644 index 0000000..f738b4d --- /dev/null +++ b/2209040027/Design of Student Adress Book Management System/README.md @@ -0,0 +1,10 @@ +#设计一个学生通信录,学生通迅录数据信息构成内容可自行设计(如:学号、姓名、电话号码、所在班级、寝室地址等),通信录数据类型定义为结构体类型。 +主要实现功能包括: +(1)创建学生通讯录; +(2)修改学生通讯录; +(3)增删学生通讯录; +(4)能够按多种方式进行查询(如:①按学号查询;②按所在班级查询) +##运行软件 +Dev-C++ +###操作系统 +Windows 11 Version 22H2 \ No newline at end of file diff --git "a/2209040027/Design of Student Adress Book Management System/\345\255\246\347\224\237\351\200\232\350\256\257\345\275\225\347\256\241\347\220\206\347\263\273\347\273\237\350\256\276\350\256\241.c" "b/2209040027/Design of Student Adress Book Management System/\345\255\246\347\224\237\351\200\232\350\256\257\345\275\225\347\256\241\347\220\206\347\263\273\347\273\237\350\256\276\350\256\241.c" new file mode 100644 index 0000000..c89caa8 --- /dev/null +++ "b/2209040027/Design of Student Adress Book Management System/\345\255\246\347\224\237\351\200\232\350\256\257\345\275\225\347\256\241\347\220\206\347\263\273\347\273\237\350\256\276\350\256\241.c" @@ -0,0 +1,594 @@ +#include /*ͷļ*/ +#include //õϵͳ +#include //ַĺͷļ +#include + +//ṹ +struct tongxunlu /*ͨѶ¼ṹ*/ +{ + char xingming[20]; /*ֵ*/ + char dianhua[20]; /*绰*/ + char dizhi[40]; /*ַ*/ +} txl[100]; //Ĭ100 +int n=0;//¼ϵ +FILE *fp; /*ļ*/ +//õк +void zhucaidan(); /*˵*/ +void zengjia(); /*ϵ˺*/ +void readfile(); /*ļж뺯*/ +void writefile(); /*ļд뺯*/ +void xiugai(); /*޸ϵ˺*/ +void xiugai_xingming(); /*޸*/ +void xiugai_dianhua(); /*绰޸*/ +void chazhao(); /*ϵ˺*/ +void chazhao_xingming(); /**/ +void chazhao_dianhua(); /**/ +void shanchu(); /*ɾϵ˺*/ +void shanchu_quanbu(); /*ȫɾ*/ +void shanchu_dange(); /*ɾ*/ +void xianshi(); /*ʾ*/ +// ģ +int main() /*main*/ +{ + readfile(); /*ļ*/ + while(1) /* ѭԶУ*/ + { + zhucaidan(); /*˵*/ + } + return 0; +} +//ȡļֿʼ ģ +void readfile() +{ + if((fp=fopen("txl.txt","r"))==NULL) /*ֻʽжļǷΪ*/ + { + printf("\n\t\t\t ͨѶ¼ļ"); /*жϽ*/ + if ((fp=fopen("txl.txt","w"))==NULL) /*ֻдʽж*/ + { + printf("\n\t\tʧ"); /*Ϊս*/ + exit(0); /*˳*/ + } + else /*Ϊִelse*/ + { + printf("\n\t-----------------ӭʹͨѶ¼ϵͳ------------------"); + printf("\n\t ͨѶ¼ļѽ "); + printf("\n\t ˵ "); + printf("\n\t---------------------------------------------------------"); + getch(); + return ; + } + exit(0); + } + fseek(fp,0,2); /*ļλָƶļĩβ*/ + if (ftell(fp)>0) /*ļΪ*/ + { + rewind(fp); /*ļλָƶļʼλ*/ + for (n=0; !feof(fp) && fread(&txl[n],sizeof(struct tongxunlu),1,fp); n++); + printf("\n\t---------- ӭʹͨѶ¼ϵͳ ----------------"); + printf("\n\t ļɹ "); + printf("\n\t ˵ "); + printf("\n\t---------------------------------------------------------"); + getch(); + return; + } + printf("\n\t------------ ӭʹͨѶ¼ϵͳ --------------"); + printf("\n\t ļɹ "); + printf("\n\t ͨѶ¼ļκμ¼ "); + printf("\n\t ˵ "); + printf("\n\t---------------------------------------------------------"); + getch(); + return; +} +//ȡļ + +//ļ˵ʼ ģ +void zhucaidan() +{ + char c; + system("cls"); + printf("\n\t\t|------- ӭʹͨѶ¼ϵͳ -----|"); + printf("\n\t\t| 1-ϵ 2-ѯʾϵ |"); + printf("\n\t\t| 3-ɾϵ 4-޸ϵ |"); + printf("\n\t\t| 5-˳ 0-˳ |"); + printf("\n\t\t|------------------------------------------------|"); + printf("\n\t\tѡҪķ"); + c=getch(); + switch (c) /*ϱߵѡĿ*/ + { + case '1': + zengjia(); + break; + case '2': + chazhao(); + break; + case '3': + shanchu(); + break; + case '4': + xiugai(); + break; + case '5': + writefile(); + break; + case '0': + exit(0); + default: + zhucaidan(); /*û򷵻˵ȴ*/ + } +} +//ļ˵ + +//ϵ˺ʼ ģһ +void zengjia() +{ + printf("\n\t\t------------------ ϵϢ --------------------\n"); + printf("\n\t\tϵ:"); + scanf("%s",txl[n].xingming); /**/ + printf("\n\t\tϵ˵绰:"); + scanf("%s",txl[n].dianhua); + printf("\n\t\tϵ˵ַ:"); + scanf("%s",txl[n].dizhi); + n++; /*ͳƸ*/ + printf("\n\t\tǷϵ?(Y/N):"); /*Ƿϵ.*/ + if (getch()=='y') + zengjia(); + return; +} +//ϵ˽ +//дļʼ ģ +void writefile() /*ϵдļ*/ +{ + int i; + if ((fp=fopen("txl.txt","w"))==NULL) + { + printf("\n\t\tļʧ"); + } + for (i=0; i +#include +#include +#define MAX 300 // + +struct Student{ //ѧݽṹ + char name[10]; // + char num[20]; //ѧ + char localcity[30]; //弮 +}; +struct Data{ + int count; //ѧ + struct Student stu[MAX]; //ѧ +}data; + +void Choice(){ //˵ + system("cls"); + printf("***************ѧϢ¼****************\n"); + printf("* 0.˳ϵͳ *\n"); + printf("* 1.¼Ϣ *\n"); + printf("* 2.ѯϢ *\n"); + printf("* 3.Ϣ *\n"); + printf("* 4.޸Ϣ *\n"); + printf("* 5.ɾϢ *\n"); + printf("*****************************************************\n"); + printf("\t\tһ<0-5>\n"); + int choice; + while(1){ + printf("ѡ"); + scanf("%d",&choice); + switch(choice){ + case 0: + exit(0); + break; + case 1: + Add(); + break; + case 2: + Search(); + break; + case 3: + Browse(); + break; + case 4: + Amend(); + break; + case 5: + Delete(); + break; + default: + printf("ѡ"); + Choice(); + break; + } + } +} + +void Add(){ //Ӻ + int i,flag=0; + char choice,name[10],num[20],localcity[30]; + while(1){ + printf("Ƿ[y/n]"); + scanf("%s",&choice); + if(choice!='y') + break; + else{ + printf("ѧѧţ᣺"); + scanf("%s%s%s",&name,&num,&localcity); + } + for(i=0;i\n"); + int choice; + while(1){ + printf("ѡ"); + scanf("%d",&choice); + switch(choice){ + case 0: + Choice(); + break; + case 1: + Bynum(); + break; + case 2: + Byname(); + break; + case 3: + Bylocalcity(); + break; + default: + printf("ѡ"); + Search(); + break; + } + } +} + +void Bynum(){ //ѧŲѯ + char num[20]; + int key,flag=0,i; + system("cls"); + printf("ѧţ"); + scanf("%s",&num); + for(i=0;i