You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pvqegfn3u/通讯录程序设计.c

221 lines
5.3 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h>
#include<string.h>//<2F><>׼<EFBFBD><EFBFBD><E2BAAF>
struct stu{//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ
char n[15];//<2F><><EFBFBD><EFBFBD>
char d[15];//<2F><><EFBFBD><EFBFBD>
char y[15],g[15];//<2F><EFBFBD><E7BBB0><EFBFBD><EFBFBD>1<EFBFBD>͵绰<CDB5><E7BBB0><EFBFBD><EFBFBD>2
char e[20]; //<2F><><EFBFBD><EFBFBD>
};
struct stu s[100];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
FILE *fp;//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int N;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void luru();//¼<><C2BC><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
void xiuzheng();//Ϊ<>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸<EFBFBD>
void xiugai();//<2F>޸<EFBFBD><DEB8><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
void shuchu();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
void baocun(int t);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
void chazhao();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
void wel();//<2F>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>
void main()
{
do{ system("cls");//<2F><><EFBFBD><EFBFBD>
wel();
scanf("%d",&N);
if(N==0)
break;
switch(N)
{
case 1:luru(); break;
case 2:shuchu(); break;
case 3:chazhao(); break;
case 4:xiuzheng(); break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
}
}while(1);//do-whileʵ<65>ֳ<EFBFBD><D6B3><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
void wel()
{
printf(" ");
printf(" <20><>ӭʹ<D3AD><CAB9>ͨѶ¼<D1B6><C2BC><EFBFBD><EFBFBD>ϵͳ\n\n\n");
printf(" ");
printf("<><C2BC><EFBFBD><EFBFBD>Ϣ<EFBFBD>밴1\n\n");
printf(" ");
printf(" *<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>밴2\n\n");
printf(" ");
printf(" *<2A><>ѯ<EFBFBD><D1AF>Ϣ<EFBFBD>밴3\n\n");
printf(" ");
printf(" *<2A>޸<EFBFBD><DEB8><EFBFBD>Ϣ<EFBFBD>밴4\n\n");
printf(" ");
printf(" *<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹ<EFBFBD>밴0\n\n");
}
void luru()//ʵ<><CAB5>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
{
int i=0,v,t;//iΪ<69><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC>ַ<EFBFBD><D6B7><76>ж<EFBFBD>ѭ<EFBFBD><D1AD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>t<EFBFBD><74>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6BAAF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
do{ system("cls");//<2F><><EFBFBD><EFBFBD>
fflush(stdin);//<2F><><EFBFBD><EFBFBD><EFBFBD>ڴ滺<DAB4><E6BBBA><EFBFBD><EFBFBD>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD>ϵ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>\n",i+1);
gets(s[i].n);
fflush(stdin);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD>ϵ<EFBFBD>˵ļ<CBB5><C4BC><EFBFBD>\n",i+1);
gets(s[i].d);
fflush(stdin);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD>ϵ<EFBFBD>˵ĵ绰<C4B5><E7BBB0><EFBFBD><EFBFBD>1\n",i+1);
scanf("%s",&s[i].y);
fflush(stdin);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD>ϵ<EFBFBD>˵ĵ绰<C4B5><E7BBB0><EFBFBD><EFBFBD>2\n",i+1);
scanf("%s",&s[i].g);
fflush(stdin);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD>ϵ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>\n",i+1);
gets(s[i].e);
fflush(stdin);
i=i+1;//Ϊ<><CEAA>һ<EFBFBD><D2BB>ѭ<EFBFBD><D1AD>׼<EFBFBD><D7BC>
t=i;
system("cls");//<2F><><EFBFBD><EFBFBD>
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>밴1,ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD>밴0\n");
scanf("%d",&v);
}while(v==1);
baocun(t);
printf("¼<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
system("pause");//<2F><>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
}
void shuchu()//<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
int i,n;//iΪ<69><EFBFBD><E1B9B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>
system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
if((fp=fopen("ͨѶ¼.txt","r"))==NULL)//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
{
printf("File open error!\n");
exit(0);
}
for(i=0;feof(fp)==0;i++)
{
fscanf(fp,"%s%s%s%s%s",s[i].n,s[i].d,&s[i].y,&s[i].g,s[i].e);//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
}
fclose(fp);//<2F>ر<EFBFBD><D8B1>ļ<EFBFBD>
for(n=0;n<=i;n++)
printf("%s\t%s\t%s\t\t%s\t\t%s\n",s[n].n,s[n].d,s[n].y,s[n].g,s[n].e);//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
system("pause");
}
void xiugai(int n)//<2F>޸<EFBFBD><DEB8><EFBFBD><EFBFBD><EFBFBD>
{ int b,k;//bΪѡ<CEAA><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸Ķ<DEB8>Ӧ<EFBFBD><D3A6>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><6B>ж<EFBFBD><D0B6>޸<EFBFBD><DEB8>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><C4B1><EFBFBD>
do{
system("cls");
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("1:<3A><><EFBFBD><EFBFBD> 2:<3A><>ַ 3:<3A><EFBFBD><E7BBB0><EFBFBD><EFBFBD>1 4:<3A><EFBFBD><E7BBB0><EFBFBD><EFBFBD>2 5.<2E><><EFBFBD><EFBFBD>\n");
scanf("%d",&b);
switch(b)
{
case 1: printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");scanf("%s",s[n].n); break;
case 2: printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");scanf("%s",s[n].d); break;
case 3: printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");scanf("%s",s[n].y); break;
case 4: printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");scanf("%s",s[n].g); break;
case 5: printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");scanf("%s",s[n].e); break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
}
printf("<EFBFBD>޸ijɹ<EFBFBD>\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><EFBFBD>밴1 <09>˳<EFBFBD><CBB3>޸<EFBFBD><DEB8>밴0\n");
scanf("%d",&k);
if(k==0)
break;
}while(1);//<2F>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽ<EFBFBD><DDBD><EFBFBD><EFBFBD>޸<EFBFBD>
}
void xiuzheng()//<2F>ҵ<EFBFBD><D2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>˵ĵ<CBB5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>
{ int i,n=0,k=0,t;
char c[20];
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%s",c);
if((fp=fopen("ͨѶ¼.txt","r+"))==NULL)//<2F><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD>д
{
printf("File open error!\n");
exit(0);
}
for(i=0;feof(fp)==0;i++)
{
fscanf(fp,"%s %s %s %s %s\n",s[i].n,s[i].d,s[i].y,s[i].g,s[i].e);
if(strcmp(c,s[i].n)==0)
{
n=i;
k++;
}
}
if(k==i)
{
printf("<EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD>\n");
}
printf("<EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><EFBFBD>\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD>ַ\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("%s\t%s\t%s\t%s\t\t%s\n",s[n].n,s[n].d,s[n].y,s[n].g,s[n].e);//<2F><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
printf("ȷ<EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD><EFBFBD>밴1 <09>˳<EFBFBD><CBB3>޸<EFBFBD><DEB8>밴2\n");
scanf("%d",&t);
if(t==1)
xiugai(n);
if(fclose(fp))//<2F><><EFBFBD>޸<EFBFBD><DEB8><EFBFBD>Ϣ<EFBFBD>˳<EFBFBD>
{
printf("<EFBFBD>ر<EFBFBD>ʧ<EFBFBD><EFBFBD>\n");
exit(0);
}
if((fp=fopen("ͨѶ¼.txt","w"))==NULL)
{
printf("File open error!\n");
exit(0);
}
for(n=0;n<i;n++)
fprintf(fp,"%s %s %s %s %s\n",s[n].n,s[n].d,s[n].y,s[n].g,s[n].e);
if(fclose(fp))
{
printf("<EFBFBD>ر<EFBFBD>ʧ<EFBFBD><EFBFBD>\n");
exit(0);
}
system("pause");
}
void chazhao()//<2F><>Ϣ<EFBFBD><CFA2><EFBFBD>ҹ<EFBFBD><D2B9><EFBFBD>
{
int i,n=0;//nΪ<6E><CEAA>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
char name[20];//<2F><><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
system("cls");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%s",name);
if((fp=fopen("ͨѶ¼.txt","r"))==NULL)//<2F><><EFBFBD>ļ<EFBFBD>
{
printf("File open error!\n");
exit(0);
}
for(i=0;feof(fp)==0;i++)
{
fscanf(fp,"%s%s%s%s%s",s[i].n,s[i].d,s[i].y,s[i].g,s[i].e);
if(strcmp(name,s[i].n)==0||strcmp(name,s[i].e)==0||strcmp(name,s[i].y)==0||strcmp(name,s[i].g)==0)//<2F>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȷ
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> \t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("%s\t%s\t%s\t\t%s\t\t%s\n",s[i].n,s[i].d,s[i].y,s[i].g,s[i].e);
}
else
n++;//<2F><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
}
if(i==n)
printf("<EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD>ˣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
if(fclose(fp))
{
printf("<EFBFBD>ر<EFBFBD>ʧ<EFBFBD><EFBFBD>\n");
exit(0);
}
system("pause");
}
void baocun(int t)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
{
int i;
if((fp=fopen("ͨѶ¼.txt","a"))==NULL)
{ printf("error\n");
exit(0);
}
for(i=0;i<t;i++)
{
fprintf(fp,"%s %s %s %s %s\n",s[i].n,s[i].d,s[i].y,s[i].g,s[i].e);
}
if(fclose(fp))
{
printf("<EFBFBD>ر<EFBFBD>ʧ<EFBFBD><EFBFBD>\n");
exit(0);
}
}