commit cc4ca16329efa8d239ea2e3fe948b45c8abe163c Author: 易美美 <18408200314@stu.hut.edu.cn> Date: Tue Jan 8 09:19:45 2019 +0800 first commit diff --git a/01.cpp b/01.cpp new file mode 100644 index 0000000..691833b --- /dev/null +++ b/01.cpp @@ -0,0 +1,220 @@ +#include +#include +#include +#include +#define N 100 +struct student +{ +char id[10]; +char name[25]; +char sex[10]; +int age; +char jiguan[25]; +char xibie[25]; +char zhuanye[25]; +int ban; +}stu[N]; +void menu() +{ +int choice,w1; +void add();void find();void shanchu();void change();void tongji();void read();void input(); +do +{ +puts("\t--------------------------------------------------------"); + puts("\t| »¶Ó­Ê¹ÓÃѧ¼®¹ÜÀíϵͳ |"); + puts("\t|------------------------------------------------------|"); + puts("\t| 1.¼ÈëѧÉú×ÊÁÏ |"); + puts("\t| 2.²éÕÒѧÉú×ÊÁÏ |"); + puts("\t| 3.ɾ³ýѧÉú×ÊÁÏ |"); + puts("\t| 4.ÐÞ¸ÄѧÉú×ÊÁÏ |"); + puts("\t| 5.°´Ñ§ºÅ»òרҵÊä³öѧÉú×ÊÁÏ |"); + puts("\t| 6.²é¿´ËùÓÐѧÉú×ÊÁÏ |"); + puts("\t| 7.Í˳öϵͳ |"); + puts("\t--------------------------------------------------------"); + printf("ÏëÑ¡ÔñµÄ¹¦ÄÜ£º"); + +scanf("%d",&choice); +if(choice<1||choice>8) +{w1=1;system("cls");printf("²Ëµ¥Ñ¡Ôñ´í£¬ÇëÖØÐÂÑ¡Ôñ£¡\n");} +else w1=0; +}while(w1==1); +switch (choice) +{ +case 1: +add(); +break; +case 2: +find(); +break; +case 3: +shanchu(); +break; +case 4: +change(); +break; +case 5: +tongji(); +break; +case 6: +read(); +break; +case 7: +break; +default: exit(0); +} +} +int load() +{ +FILE *fp; +int i; +if ((fp=fopen("results.txt","rb"))==NULL) +{ +printf("Îļþ´ò¿ª´íÎó"); +return 0; +} +for (i=0;!feof(fp);i++)fread(&stu[i],sizeof(struct student),1,fp); +fclose(fp); +return(i-1); +} +void save(int n) +{ +int i; +FILE *fp; +if ((fp=fopen("results.txt","wb"))==NULL) +{ +printf("Îļþ´ò¿ª´íÎó:"); +} +for (i=0;i2) +{xz=1;system("cls");printf("ÊäÈë´íÎó£¬ÇëÖØÐÂÑ¡Ôñ£¡\n");} +else xz=0; +}while(xz==1); +switch(choice) +{ +case 1: +menu(); break; +case 2: +exit(0); break; +} +} +} +void add() +{ +FILE *fp; +int i,n,m; +n=load(); +if ((fp=fopen("results.txt","wb"))==NULL) +{ +printf("Îļþ´ò¿ª´íÎó!\n"); +exit(1); +} +printf("ÄãÏëҪ¼Èë¶àÉÙ¸öѧÉúÐÅÏ¢?"); +scanf("%d",&m); +for (i=0;i2) +{xz=1;system("cls");printf("ÊäÈë´íÎó£¬ÇëÖØÐÂÑ¡Ôñ£¡\n");} +else xz=0; +}while(xz==1); +switch(choice) +{ +case 1: +menu(); break; +case 2: +exit(0); break; +} +} +} +void find() +{ +int meau(); +int n,i; +char m[10]; +n=load(); +printf("\t\t\t»¶Ó­Ê¹ÓÃѧºÅ²éÕÒ¹¦ÄÜ\nÇëÊäÈëÄãÐèÒª²éÕÒµÄѧÉúµÄѧºÅ:"); +scanf("%s",&m); +for (i=0;i2) +{xz=1;system("cls");printf("ÊäÈë´íÎó£¬ÇëÖØÐÂÑ¡Ôñ£¡\n");} +else xz=0; +}while(xz==1); +switch(choice) +{ +case 1: +menu(); break; +case 2: +exit(0); break; +} +} +} +