手机通讯录如何导出范文
手机通讯录如何导出范文第1篇
int Count=0; FILE *fp; void new_friend(struct friends_list friends[]); void show_friend(struct friends_list friends[]); void search_friend(struct friends_list friends[]); void statistics_friend(struct friends_list friends[]); void xiugai_friend(struct friends_list friends[]); void shanchu_friend(struct friends_list friends[]); int main(void) { int choice; char name[10];char sn[12]; struct friends_list friends[50]; do{ printf(" *********************************************** "); printf(" $ $ "); printf(" $ 学生通讯系统功能选项 $ "); printf(" $ $ "); printf(" *********************************************** "); printf(" 1:新建2:显示3:查询4:统计5:修改6:删除0:退出 "); printf("请选择功能:"); scanf("%d",&choice);
switch(choice){ case 1:
new_friend(friends);
break;
case 2: show_friend(friends);
break; case 3: search_friend(friends);
break; case 4: statistics_friend(friends); break; case 5: xiugai_friend(friends);
break; case 6: shanchu_friend(friends);
break; case 0:
break;
} }while(choice!=0); printf("谢谢使用通讯录功能! "); return 0; }
//新建
void new_friend(struct friends_list friends[]) { struct friends_list f;int choice; if(Count==50){
printf("通讯录已满! ");
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("您添加了一个记录,内容如下: "); printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); printf(" 姓名性别班级学号地址电话年龄 "); printf(" %s %s %s %s %s %s %s ",f.name,f.sex,f.banji,f.sn,f.address,f.telephone,f.age); printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ");
printf("您确定要添加吗<1:确定:否>?"); scanf("%d",&choice); if(choice==1){
fp=fopen("file1.txt","a");
fprintf(fp,"%s %s %s %s %s %s %s ",f.name,f.sex,f.banji,f.sn,f.address,f.telephone,f.age);
fclose(fp); printf(" & & & & & & & & "); printf(" &您已添加成功& "); printf(" & & & & & & & & ");
} else
return; friends[Count]=f; Count++; }
//显示
void show_friend(struct friends_list friends[]) { struct friends_list f;
printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); printf(" 姓名性别班级学号地址电话年龄 "); printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); fp=fopen("file1.txt","r"); while(!feof(fp)){ fscanf(fp,"%s %s %s %s %s %s %s ",&f.name,&f.sex,&f.banji,&f.sn,&f.address,&f.telephone,&f.age); printf(" %s %s %s %s %s %s %s ",f.name,f.sex,f.banji,f.sn,f.address,f.telephone,f.age); } fclose(fp);
printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); }
//查询
void search_friend(struct friends_list friends[]) { char name[10];char sn[12]; int i,flag=0,a=0;int choice=0; struct friends_list f; fp=fopen("file1.txt","r"); while(!feof(fp)){ fscanf(fp,"%s %s %s %s %s %s %s ",&f.name,&f.sex,&f.banji,&f.sn,&f.address,&f.telephone,&f.age); printf(" %s %s %s %s %s %s %s ",f.name,f.sex,f.banji,f.sn,f.address,f.telephone,f.age); a++;}
printf("一共有记录数为:%d ",a); printf("请选择查询方法<1:按姓名:按学号>"); scanf("%d",&choice); if(choice==1){
printf("^ ^您选择了按姓名查询 "); printf("请输入要查询学生的姓名:"); scanf("%s",name); fp=fopen("file1.txt","r"); for(i=0;i
&friends[i].address,&friends[i].telephone,&friends[i].age); if(strcmp(name,friends[i].name)==0){
printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); printf(" 姓名性别班级学号地址电话年龄 "); printf(" %s %s %s %s %s %s %s ",friends[i].name,friends[i].sex,friends[i].banji,friends[i].sn,
friends[i].address,friends[i].telephone,friends[i].age); printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); }
else
printf("无此联系人! "); }
} if(choice==2){ printf("^ ^您选择了按学号查询"); printf("请输入要查询学生的学号:"); scanf("%s",&sn); fp=fopen("file1.txt","r"); for(i=0;i
&friends[i].address,&friends[i].telephone,&friends[i].age); if(strcmp(sn,friends[i].sn)==0){ printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); printf(" 姓名性别班级学号地址电话年龄 "); printf(" %s %s %s %s %s %s %s ",f.name,f.sex,f.banji,f.sn,
f.address,f.telephone,f.age); printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); }
else
printf("无此联系人! ");
} fclose(fp); } } //统计
void statistics_friend(struct friends_list friends[]) { int s=0; int b=0; int i,flag=0,a=0; int choice=0; char banji[10]; char sex[12];
struct friends_list f; a++;
printf("一共有学生的数目:%d ",a); printf("请选择查询方法<1:按班级:按性别>"); scanf("%d",&choice);
if(choice==1){
printf("~ ~您选择了按班级查询 "); printf("请输入要查询学生的班级:"); scanf("%s",banji); fp=fopen("file1.txt","r"); for(i=0;i
&friends[i].address,&friends[i].telephone,&friends[i].age); if(strcmp(banji,friends[i].banji)==0) b++; } printf("%s共有%d个学生 ",banji,b); } if(choice==2){
printf("~ ~您选择了按性别查询 "); printf("请输入要查询学生的性别:"); scanf("%s",sex); fp=fopen("file1.txt","r"); for(i=0;i
&friends[i].address,&friends[i].telephone,&friends[i].age); if(strcmp(sex,friends[i].sex)==0) s++; } printf("%s共有%d个学生 ",sex,s); } fclose(fp); } //修改
void xiugai_friend(struct friends_list friends[]) { char name[10];char sn[12]; int i;int choice=0;char ch[12];
printf("请选择查询方法<1:按姓名:按学号>"); scanf("%d",&choice); if(choice==1){
printf("* *您选择了按姓名查询 "); printf("请输入要查询学生的姓名:"); scanf("%s",name);} else{ printf("* *您选择了按学号查询"); printf("请输入要查询学生的学号:"); scanf("%s",&sn); } fp=fopen("file1.txt","r"); for(i=0;i
&friends[i].address,&friends[i].telephone,&friends[i].age); if((strcmp(name,friends[i].name)==0)||(strcmp(sn,friends[i].sn)==0)){ printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); printf(" 姓名性别班级学号地址电话年龄 "); printf(" %s %s %s %s %s %s %s ",friends[i].name,friends[i].sex,friends[i].banji,friends[i].sn,
friends[i].address,friends[i].telephone,friends[i].age); printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ");
printf("请选择要修改的项目<1:姓名:性别:班级:学号:地址:电话:年龄:退出>: "); scanf("%d",&choice); printf("请输入要修改的内容:"); scanf("%s",ch);
switch(choice){
case 1: strcpy(friends[i].name,ch);
break; case 2: strcpy(friends[i].sex,ch);
break; case 3: strcpy(friends[i].banji,ch); break; case 4: strcpy(friends[i].sn,ch); break; case 5: strcpy(friends[i].address,ch);
break; case 6:
strcpy(friends[i].telephone,ch);
break; case 7: strcpy(friends[i].age,ch);
break; case 0: break; } printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); printf(" 修改后的信息如下: "); printf(" 姓名性别班级学号地址电话年龄 "); printf(" %s %s %s %s %s %s %s ",friends[i].name,friends[i].sex,friends[i].banji,friends[i].sn,
friends[i].address,friends[i].telephone,friends[i].age); printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); printf(" & & & & & & & & "); printf(" &您已添加成功& "); printf(" & & & & & & & & "); } } fclose(fp); } //删除
void shanchu_friend(struct friends_list friends[]) { int i; int choice=0; char name[10]; char sn[12]; char ch[12];
printf("请选择查询方法<1:按姓名:按学号>"); scanf("%d",&choice); if(choice==1){
printf("& &您选择了按姓名删除 "); printf("请输入要删除学生的姓名:"); scanf("%s",name); } if(choice==2){ printf("& &您选择了按学号删除"); printf("请输入要删除学生的学号:"); scanf("%s",&sn); } fp=fopen("file1.txt","r"); for(i=0;i
&friends[i].address,&friends[i].telephone,&friends[i].age); if((strcmp(name,friends[i].name)==0)||(strcmp(sn,friends[i].sn)==0)){ printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); printf(" 姓名性别班级学号地址电话年龄 "); printf(" %s %s %s %s %s %s %s ",friends[i].name,friends[i].sex,friends[i].banji,friends[i].sn,
friends[i].address,friends[i].telephone,friends[i].age); printf(" ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ "); printf("是否删除?<1:是:否>:"); scanf("%d",&choice); if(choice==1){ printf(" & & & & & & & & "); printf(" &您已删除成功& "); printf(" & & & & & & & & ");
} else
手机通讯录如何导出范文
声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。如若本站内容侵犯了原著者的合法权益,可联系本站删除。


