C程序课题设计-通讯录系统
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
};
void officenumbersearch(ADDRESS adr[],int length){
printf("请输入办公电话:\n");
scanf("%s",&in);
for(i=0;i<length;++i)if(strcmp(adr[i].teleOff,in)==0)printf(strFmt,adr[i].ID,adr[i].name,adr[i].workPlace,adr[i].teleOff,adr[i].teleHome);
++cntAddr;
}
}
fclose(fp);
return cntAddr;
};
void list(ADDRESS addr[],int length){
for(i=0;i<length;++i)printf(strFmt,addr[i].ID,addr[i].name,addr[i].workPlace,addr[i].teleOff,addr[i].teleHome);
fclose(fp);
};
void unitssort(ADDRESS addr[],int length){
for(i=0;i<length;++i)addrTmp[i]=addr[i];
for(i=0;i<length-1;++i)for(j=i+1;j<length;++j)if(strcmp(addrTmp[i].workPlace,addrTmp[j].workPlace)>0){adTmp=addrTmp[i];addrTmp[i]=addrTmp[j];addrTmp[j]=adTmp;}
#include <string.h>
#include <stdio.h>
#include<stdlib.h>
int cntAddr=0,i,j;
char in[12];
const char * strFmt="\n%d\t%s\t%s\t%s\t%s\n";
typedef struct ADDRESSD {
};
void homenumbersearch(ADDRESS adr[],int length){
printf("请输入家庭电话:\n");
scanf("%s",&in);
for(i=0;i<length;++i)if(strcmp(adr[i].teleHome,in)==0)printf(strFmt,adr[i].ID,adr[i].name,adr[i].workPlace,adr[i].teleOff,adr[i].teleHome);
for(i=0;i<length;++i)printf(strFmt,addrTmp[i].ID,addrTmp[i].name,addrTmp[i].workPlace,addrTmp[i].teleOff,addrTmp[i].teleHome);
};
void save(ADDRESS adr[],int length){
++cntAddr;
}
return cntAddr;
};
void showpaixu(ADDRESS adr[],int length)
{
int choice;
menu1:
system("cls");
printf("\n\n\n\n *************************通讯录信息管理系统*************************\n\n");
int ID;
char name[12];
char workPlace[12];
char teleOff[12];
char teleHome[12];
}ADDRESS;
ADDRESS addrTmp[100],adTmp;
int load(ADDRESS adr[]){
FILE *fp;
printf("要修改第几条记录:\n");
scanf("%d",&j);
printf("请输入ID:\n");
scanf("%d",&i);
adr[j].ID=i;
printf("请输入姓名:\n");
scanf("%s",in);
strcpy(adr[j].name,in);
if(scanf("%s",in)==EOF)break;
strcpy(adr[cntAddr].name,in);
printf("请输入工作单位:\n");
if(scanf("%s",in)==EOF)break;
strcpy(adr[cntAddr].workPlace,in);
}
void display(ADDRESS addr[]){
for(i=0;i<cntAddr;++i)addrTmp[i]=addr[i];
for(i=0;i<cntAddr-1;++i)for(j=i+1;j<cntAddr;++j)if(addrTmp[i].ID>addrTmp[j].ID){adTmp=addrTmp[i];addrTmp[i]=addrTmp[j];addrTmp[j]=adTmp;}
printf("请输入办公电话:\n");
if(scanf("%s",in)==EOF)break;
strcpy(adr[cntAddr].teleOff,in);
printf("请输入家庭电话:\n");
if(scanf("%s",in)==EOF)break;
strcpy(adr[cntAddr].teleHome,in);
for(i=0;i<length;++i)addrTmp[i]=addr[i];
for(i=0;i<length-1;++i)for(j=i+1;j<length;++j)if(strcmp(addrTmp[i].name,addrTmp[j].name)>0){adTmp=addrTmp[i];addrTmp[i]=addrTmp[j];addrTmp[j]=adTmp;}
FILE *fp;
fp=fopen("c:\\txl.txt","w");
for(i=0;i<cntAddr;++i)fprintf(fp,"%d %s %s %s %s ",adr[i].ID,adr[i].name,adr[i].workPlace,adr[i].teleOff,adr[i].teleHome);
printf("请输入工作单位:\n");
scanf("%s",in);
strcpy(adr[j].workPlace,in);
printf("请输入办公电话:\n");
scanf("%s",in);
strcpy(adr[j].teleOff,in);
printf("请输入家庭电话:\n");
scanf("%s",in);
strcpy(adr[j].teleHome,in);
};
int add(ADDRESS adr[],int length){
printf("请输入ID:\n");
scanf("%d",&i);
adr[length].ID=i;
printf("请输入姓名:\n");
if((fp=fopen("c:\\txl.txt","r"))!=NULL){
cntAddr=0;
while(!feof(fp)){
fscanf(fp,"%d %s %s %s %s ",&(adr[cntAddr].ID),adr[cntAddr].name,adr[cntAddr].workPlace,adr[cntAddr].teleOff,adrБайду номын сангаасcntAddr].teleHome);
cntAddr=0;
printf("请按次序输入数据,结束按CTRL+z:\n");
while(1){
printf("请输入ID:\n");
if(scanf("%d",&i)==EOF)break;
adr[cntAddr].ID=i;
printf("请输入姓名:\n");
};
void unitssearch(ADDRESS adr[],int length){
printf("请输入工作单位:\n");
scanf("%s",&in);
for(i=0;i<length;++i)if(strcmp(adr[i].workPlace,in)==0)printf(strFmt,adr[i].ID,adr[i].name,adr[i].workPlace,adr[i].teleOff,adr[i].teleHome);
for(i=0;i<cntAddr;++i)printf(strFmt,addrTmp[i].ID,addrTmp[i].name,addrTmp[i].workPlace,addrTmp[i].teleOff,addrTmp[i].teleHome);
}
void namesort(ADDRESS addr[],int length){
for(i=0;i<length;++i)printf(strFmt,addrTmp[i].ID,addrTmp[i].name,addrTmp[i].workPlace,addrTmp[i].teleOff,addrTmp[i].teleHome);
};
void namesearch(ADDRESS addr[],int length){
printf("请输入姓名:\n");
scanf("%s",&in);
for(i=0;i<length;++i)if(strcmp(addr[i].name,in)==0)printf(strFmt,addr[i].ID,addr[i].name,addr[i].workPlace,addr[i].teleOff,addr[i].teleHome);
};
int delet(ADDRESS adr[],int length){
printf("要修改第几条记录:\n");
scanf("%d",&j);
for(i=j;i<length-1;++i)adr[i]=adr[i+1];
return --length;
};
void rewrite(ADDRESS adr[],int length){
scanf("%s",in);
strcpy(adr[length].name,in);
printf("请输入工作单位:\n");
scanf("%s",in);
strcpy(adr[length].workPlace,in);
printf("请输入办公电话:\n");
scanf("%s",in);
fprintf(fc,"%d %s %s %s %s ",adTmp.ID,,adTmp.workPlace,adTmp.teleOff,adTmp.teleHome);
}
fclose(fc);
}
fclose(fp);
};
int enter(ADDRESS adr[]){
strcpy(adr[length].teleOff,in);
printf("请输入家庭电话:\n");
scanf("%s",in);
strcpy(adr[length].teleHome,in);
return ++cntAddr;
};
void copy(){
FILE *fp,*fc;
printf("请输入新文件名(路径中的反斜杠用\\表示)\n");
scanf("%s",&in);
if((fp=fopen("c:\\txl.txt","r"))!=NULL){
fc=fopen(in,"w");
while(!feof(fp)){
fscanf(fp,"%d %s %s %s %s ",&(adTmp.ID),,adTmp.workPlace,adTmp.teleOff,adTmp.teleHome);
void officenumbersearch(ADDRESS adr[],int length){
printf("请输入办公电话:\n");
scanf("%s",&in);
for(i=0;i<length;++i)if(strcmp(adr[i].teleOff,in)==0)printf(strFmt,adr[i].ID,adr[i].name,adr[i].workPlace,adr[i].teleOff,adr[i].teleHome);
++cntAddr;
}
}
fclose(fp);
return cntAddr;
};
void list(ADDRESS addr[],int length){
for(i=0;i<length;++i)printf(strFmt,addr[i].ID,addr[i].name,addr[i].workPlace,addr[i].teleOff,addr[i].teleHome);
fclose(fp);
};
void unitssort(ADDRESS addr[],int length){
for(i=0;i<length;++i)addrTmp[i]=addr[i];
for(i=0;i<length-1;++i)for(j=i+1;j<length;++j)if(strcmp(addrTmp[i].workPlace,addrTmp[j].workPlace)>0){adTmp=addrTmp[i];addrTmp[i]=addrTmp[j];addrTmp[j]=adTmp;}
#include <string.h>
#include <stdio.h>
#include<stdlib.h>
int cntAddr=0,i,j;
char in[12];
const char * strFmt="\n%d\t%s\t%s\t%s\t%s\n";
typedef struct ADDRESSD {
};
void homenumbersearch(ADDRESS adr[],int length){
printf("请输入家庭电话:\n");
scanf("%s",&in);
for(i=0;i<length;++i)if(strcmp(adr[i].teleHome,in)==0)printf(strFmt,adr[i].ID,adr[i].name,adr[i].workPlace,adr[i].teleOff,adr[i].teleHome);
for(i=0;i<length;++i)printf(strFmt,addrTmp[i].ID,addrTmp[i].name,addrTmp[i].workPlace,addrTmp[i].teleOff,addrTmp[i].teleHome);
};
void save(ADDRESS adr[],int length){
++cntAddr;
}
return cntAddr;
};
void showpaixu(ADDRESS adr[],int length)
{
int choice;
menu1:
system("cls");
printf("\n\n\n\n *************************通讯录信息管理系统*************************\n\n");
int ID;
char name[12];
char workPlace[12];
char teleOff[12];
char teleHome[12];
}ADDRESS;
ADDRESS addrTmp[100],adTmp;
int load(ADDRESS adr[]){
FILE *fp;
printf("要修改第几条记录:\n");
scanf("%d",&j);
printf("请输入ID:\n");
scanf("%d",&i);
adr[j].ID=i;
printf("请输入姓名:\n");
scanf("%s",in);
strcpy(adr[j].name,in);
if(scanf("%s",in)==EOF)break;
strcpy(adr[cntAddr].name,in);
printf("请输入工作单位:\n");
if(scanf("%s",in)==EOF)break;
strcpy(adr[cntAddr].workPlace,in);
}
void display(ADDRESS addr[]){
for(i=0;i<cntAddr;++i)addrTmp[i]=addr[i];
for(i=0;i<cntAddr-1;++i)for(j=i+1;j<cntAddr;++j)if(addrTmp[i].ID>addrTmp[j].ID){adTmp=addrTmp[i];addrTmp[i]=addrTmp[j];addrTmp[j]=adTmp;}
printf("请输入办公电话:\n");
if(scanf("%s",in)==EOF)break;
strcpy(adr[cntAddr].teleOff,in);
printf("请输入家庭电话:\n");
if(scanf("%s",in)==EOF)break;
strcpy(adr[cntAddr].teleHome,in);
for(i=0;i<length;++i)addrTmp[i]=addr[i];
for(i=0;i<length-1;++i)for(j=i+1;j<length;++j)if(strcmp(addrTmp[i].name,addrTmp[j].name)>0){adTmp=addrTmp[i];addrTmp[i]=addrTmp[j];addrTmp[j]=adTmp;}
FILE *fp;
fp=fopen("c:\\txl.txt","w");
for(i=0;i<cntAddr;++i)fprintf(fp,"%d %s %s %s %s ",adr[i].ID,adr[i].name,adr[i].workPlace,adr[i].teleOff,adr[i].teleHome);
printf("请输入工作单位:\n");
scanf("%s",in);
strcpy(adr[j].workPlace,in);
printf("请输入办公电话:\n");
scanf("%s",in);
strcpy(adr[j].teleOff,in);
printf("请输入家庭电话:\n");
scanf("%s",in);
strcpy(adr[j].teleHome,in);
};
int add(ADDRESS adr[],int length){
printf("请输入ID:\n");
scanf("%d",&i);
adr[length].ID=i;
printf("请输入姓名:\n");
if((fp=fopen("c:\\txl.txt","r"))!=NULL){
cntAddr=0;
while(!feof(fp)){
fscanf(fp,"%d %s %s %s %s ",&(adr[cntAddr].ID),adr[cntAddr].name,adr[cntAddr].workPlace,adr[cntAddr].teleOff,adrБайду номын сангаасcntAddr].teleHome);
cntAddr=0;
printf("请按次序输入数据,结束按CTRL+z:\n");
while(1){
printf("请输入ID:\n");
if(scanf("%d",&i)==EOF)break;
adr[cntAddr].ID=i;
printf("请输入姓名:\n");
};
void unitssearch(ADDRESS adr[],int length){
printf("请输入工作单位:\n");
scanf("%s",&in);
for(i=0;i<length;++i)if(strcmp(adr[i].workPlace,in)==0)printf(strFmt,adr[i].ID,adr[i].name,adr[i].workPlace,adr[i].teleOff,adr[i].teleHome);
for(i=0;i<cntAddr;++i)printf(strFmt,addrTmp[i].ID,addrTmp[i].name,addrTmp[i].workPlace,addrTmp[i].teleOff,addrTmp[i].teleHome);
}
void namesort(ADDRESS addr[],int length){
for(i=0;i<length;++i)printf(strFmt,addrTmp[i].ID,addrTmp[i].name,addrTmp[i].workPlace,addrTmp[i].teleOff,addrTmp[i].teleHome);
};
void namesearch(ADDRESS addr[],int length){
printf("请输入姓名:\n");
scanf("%s",&in);
for(i=0;i<length;++i)if(strcmp(addr[i].name,in)==0)printf(strFmt,addr[i].ID,addr[i].name,addr[i].workPlace,addr[i].teleOff,addr[i].teleHome);
};
int delet(ADDRESS adr[],int length){
printf("要修改第几条记录:\n");
scanf("%d",&j);
for(i=j;i<length-1;++i)adr[i]=adr[i+1];
return --length;
};
void rewrite(ADDRESS adr[],int length){
scanf("%s",in);
strcpy(adr[length].name,in);
printf("请输入工作单位:\n");
scanf("%s",in);
strcpy(adr[length].workPlace,in);
printf("请输入办公电话:\n");
scanf("%s",in);
fprintf(fc,"%d %s %s %s %s ",adTmp.ID,,adTmp.workPlace,adTmp.teleOff,adTmp.teleHome);
}
fclose(fc);
}
fclose(fp);
};
int enter(ADDRESS adr[]){
strcpy(adr[length].teleOff,in);
printf("请输入家庭电话:\n");
scanf("%s",in);
strcpy(adr[length].teleHome,in);
return ++cntAddr;
};
void copy(){
FILE *fp,*fc;
printf("请输入新文件名(路径中的反斜杠用\\表示)\n");
scanf("%s",&in);
if((fp=fopen("c:\\txl.txt","r"))!=NULL){
fc=fopen(in,"w");
while(!feof(fp)){
fscanf(fp,"%d %s %s %s %s ",&(adTmp.ID),,adTmp.workPlace,adTmp.teleOff,adTmp.teleHome);