#includestdio.h#includestring.hstructfriends_list{charname[10];charage[12];chartelephone[13];charbanji[6];charsn[13];charaddress[8];charsex[4];};intCount=0;FILE*fp;voidnew_friend(structfriends_listfriends[]);voidshow_friend(structfriends_listfriends[]);voidsearch_friend(structfriends_listfriends[]);voidstatistics_friend(structfriends_listfriends[]);voidxiugai_friend(structfriends_listfriends[]);voidshanchu_friend(structfriends_listfriends[]);intmain(void){intchoice;charname[10];charsn[12];structfriends_listfriends[50];do{printf(\t***********************************************\n);printf(\t$$\n);printf(\t$学生通讯系统功能选项$\n);printf(\t$$\n);printf(\t***********************************************\n);printf(\t1:新建2:显示3:查询4:统计5:修改6:删除0:退出\n);printf(请选择功能:);scanf(%d,&choice);switch(choice){case1:new_friend(friends);break;case2:show_friend(friends);break;case3:search_friend(friends);break;case4:statistics_friend(friends);break;case5:xiugai_friend(friends);break;case6:shanchu_friend(friends);break;case0:break;}}while(choice!=0);printf(谢谢使用通讯录功能!\n);return0;}//新建voidnew_friend(structfriends_listfriends[]){structfriends_listf;intchoice;if(Count==50){printf(通讯录已满!\n);return;}printf(请输入新联系人的姓名:);scanf(%s,&f.name);printf(请输入新联系人的年龄:);scanf(%s,&f.age);printf(请输入新联系人的联系电话:);scanf(%s,&f.telephone);printf(请输入新联系人的学号:);scanf(%s,&f.sn);printf(请输入新联系人的班级:);scanf(%s,&f.banji);printf(请输入新联系人的地址:);scanf(%s,&f.address);printf(请输入新联系人的性别男/女:);scanf(%s,&f.sex);printf(您添加了一个记录,内容如下:\n);printf(\t~~~~~~~~~~~~~~~~~~~~\n);printf(\t姓名性别班级学号地址电话年龄\n);printf(\t%s%s%s%s%s%s%s\n,f.name,f.sex,f.banji,f.sn,f.address,f.telephone,f.age);printf(\t~~~~~~~~~~~~~~~~~~~~\n);printf(您确定要添加吗1:确定:否?);scanf(%d,&choice);if(choice==1){fp=fopen(file1.txt,a);fprintf(fp,%s%s%s%s%s%s%s\n,f.name,f.sex,f.banji,f.sn,f.address,f.telephone,f.age);fclose(fp);printf(\t&&&&&&&&\n);printf(\t&您已添加成功&\n);printf(\t&&&&&&&&\n);}elsereturn;friends[Count]=f;Count++;}//显示voidshow_friend(structfriends_listfriends[]){structfriends_listf;printf(\t~~~~~~~~~~~~~~~~~~~~\n);printf(\t姓名性别班级学号地址电话年龄\n);printf(\t~~~~~~~~~~~~~~~~~~~~\n);fp=fopen(file1.txt,r);while(!feof(fp)){fscanf(fp,%s%s%s%s%s%s%s\n,&f.name,&f.sex,&f.banji,&f.sn,&f.address,&f.telephone,&f.age);printf(\t%s%s%s%s%s%s%s\n,f.name,f.sex,f.banji,f.sn,f.address,f.telephone,f.age);}fclose(fp);printf(\t~~~~~~~~~~~~~~~~~~~~\n);}//查询voidsearch_friend(structfriends_listfriends[]){charname[10];charsn[12];inti,flag=0,a=0;intchoice=0;structfriends_listf;fp=fopen(file1.txt,r);while(!feof(fp)){fscanf(fp,%s%s%s%s%s%s%s\n,&f.name,&f.sex,&f.banji,&f.sn,&f.address,&f.telephone,&f.age);printf(\t%s%s%s%s%s%s%s\n,f.name,f.sex,f.banji,f.sn,f.address,f.telephone,f.age);a++;}printf(一共有记录数为:%d\n,a);printf(请选择查询方法1:按姓名:按学号);scanf(%d,&choice);if(choice==1){printf(^^您选择了按姓名查询\n);printf(请输入要查询学生的姓名:);scanf(%s,name);fp=fopen(file1.txt,r);for(i=0;ia;i++){fscanf(fp,%s%s%s%s%s%s%s\n,&friends[i].name,&friends[i].sex,&friends[i].banji,&friends[i].sn,&friends[i].address,&friends[i].telephone,&friends[i].age);if(strcmp(name,friends[i].name)==0){printf(\t~~~~~~~~~~~~~~~~~~~~\n);printf(\t姓名性别班级学号地址电话年龄\n);printf(\t%s%s%s%s%s%s%s\n,friends[i].name,friends[i].sex,friends[i].banji,friends[i].sn,friends[i].address,friends[i].telephone,friends[i].age);printf(\t~~~~~~~~~~~~~~~~~~~~\n);}elseprintf(无此联系人!\n);}}if(choice==2){printf(^^您选择了按学号查询);printf(请输入要查询学生的学号:);scanf(%s,&sn);fp=fopen(file1.txt,r);for(i=0;ia;i++){fscanf(fp,%s%s%s%s%s%s%s\n,&friends[i].name,&friends[i].sex,&friends[i].banji,&friends[i].sn,&friends[i].address,&friends[i].telephone,&friends[i].age);if(strcmp(sn,friends[i].sn)==0){printf(\t~~~~~~~~~~~~~~~~~~~~\n);printf(\t姓名性别班级学号地址电话年龄\n);printf(\t%s%s%s%s%s%s%s\n,f.name,f.sex,f.banji,f.sn,f.address,f.telephone,f.age);printf(\t~~~~~~~~~~~~~~~~~~~~\n);}elseprintf(无此联系人!\n);}fclose(fp);}}//统计voidstatistics_friend(structfriends_listfriends[]){ints=0;intb=0;inti,flag=0,a=0;intchoice=0;charbanji[10];charsex[12];structfriends_listf;a++;printf(一共有学生的数目:%d\n,a);printf(请选择查询方法1:按班级:按性别);scanf(%d,&choice);if(choice==1){printf(~~您选择了按班级查询\n);printf(请输入要查询学生的班级:);scanf(%s,banji);fp=fopen(file1.txt,r);for(i=0;ia;i++){fscanf(fp,%s%s%s%s%s%s%s\n,&friends[i].name,&friends[i].sex,&friends[i].banji,&friends[i].sn,&friends[i].address,&friends[i].telephone,&friends[i].age);if(strcmp(banji,friends[i].banji)==0)b++;}printf(%s共有%d个学生\n,banji,b);}if(choice==2){printf(~~您选择了按性别查询\n);printf(请输入要查询学生的性别:);scanf(%s,sex);fp=fopen(file1.txt,r);for(i=0;ia;i++){fscanf(fp,%s%s%s%s%s%s%s\n,&friends[i].name,&friends[i].sex,&friends[i].banji,&friends[i].sn,&friends[i].address,&friends[i].telephone,&friends[i].age);if(strcmp(sex,friends[i].sex)==0)s++;}printf(%s共有%d个学生\n,sex,s);}fclose(fp);}//修改voidxiugai_friend(structfriends_listfriends[]){charname[10];charsn[12];inti;intchoice=0;charch[12];printf(请选择查询方法1:按姓名:按学号);scanf(%d,&choice);if(choice==1){printf(**您选择了按姓名查询\n);printf(请输入要查询学生的姓名:);scanf(%s,name);}else{printf(**您选择了按学号查询);printf(请输入要查询学生的学号:);scanf(%s,&sn);}fp=fopen(f