C语言-通讯录管理系统
int xz;
printf("--------------------\n");
printf(" 1.按学号查询\n");
printf(" 2.按姓名查询\n");
printf("--------------------\n");
printf("请选择: \n");
scanf("%d",&xz);
if (xห้องสมุดไป่ตู้==1){
i++;
printf("想继续创建吗?(1.是/0.不):");
scanf("%d",&j);
if (!j)
return i;
else
printf("恭喜你,创建成功!请继续创建!\n");
}
return i;
}
int add_record(int flag)
{ int i=flag,j;
for(i;;)
printf("%s,%s,%s,%s,%s,%s\n",data[i].num,data[i].name,data[i].birthday,data[i].post,data[i].phone);
printf(" ------------------------------\n");
return 0;
}
}
int menu_select()
{
int i;
printf(" ******************** \n");
printf(" Welcome! \n ");
printf(" Form kuangmin\n");
printf(" ******************** \n");
printf(" \n");
i++;
printf("想继续添加吗?(1.是/0.不):");
scanf("%d",&j);
if (!j)
return i;
else
printf("恭喜你,添加成功!请继续添加!\n");
}
return (i);
}
int find_record()
{
int i;
char number[6];
char named[10];
printf(" **学号姓名出生年月家庭住址邮编电话**\n");
printf(" ------------------------------\n");
printf("%s,%s,%s,%s,%s,%s\n",data[i].num,data[i].name,data[i].birthday,data[i].post,data[i].phone);
printf(" **********通讯录的存储(D:\)*********\n");
printf(" ***********************************\n");
save_record(flag);
break;
case 6:
printf(" ***********************************\n");
printf(" 4.通讯者的删除\n");
printf(" 5.通讯录的存储\n");
printf(" 6.通讯者的排序\n");
printf(" 0.退出通讯录管理系统\n");
printf(" ======================\n");
printf( "请选择操作0-5 \n\n");
}
}
int save_record(int flag)
{
FILE*fp;
int i;
if ((fp=fopen("D:\\data.txt","w+"))==NULL)
{ printf("学号(12)姓名(10)出生年月(10)家庭住址(30)邮编(10)电话(15) \n");
printf(" --------------------------------------------\n");
scanf("%s%s%s%s%s%s",data[i].num,data[i].name,data[i].birthday,data[i].post, data[i].phone);
printf(" --------------------------------------------\n");
scanf("%s%s%s%s%s%s",data[i].num,data[i].name,data[i].birthday, data[i].post, data[i].phone);
{
printf("\t\t\t没有该用户的纪录");
return;
}
return;
}
void paixu_record(int flag)
{int i,j;
struct record tmp;
printf(" 1.按姓名排序\n");
printf(" 2.按学号排序\n");
scanf("%d",&i);
printf(" **************通讯录信息的添加*****************\n");
printf(" ***********************************************\n");
flag=add_record(flag);
break;
case 3:
printf(" ******************************\n");
printf(" ------------------------------\n");
printf("\t\t\t是否删除?(y/n)");
if (getch()=='y' || getch()=='Y')
{
for (j=i;j<flag-1;j++)
data[j]=data[j+1];
flag--;
printf(" ------------------------------\n");
return 0;
}
else {printf("对不起,没有你要找的人! \n");return 0;}
}
}
int delete_record(int flag)
{
int i,j;
int deletemark=0;
int save_record(int flag);
void main()
{
for( ; ; ){
switch(menu_select())
{
case 1:
printf(" ***********************************************\n");
printf(" **************通讯录的建立***************\n");
int menu_select( );
int create_record();
int add_record(int flag);
int flag=0;
int find_record(int flag);
int delete_record(int flag);
void paixu_record(int flag);
printf(" **学号姓名出生年月家庭住址邮编电话**\n");
printf(" ------------------------------\n");
printf("%s,%s,%s,%s,%s,%s\n",data[i].num,data[i].name,data[i].birthday,data[i].post,data[i].phone);
printf(" ***********************************************\n");
flag=create_record();
break;
case 2:
printf(" ***********************************************\n");
if(i==1)
{for (i=1;i<flag;i++)
{
if(strcmp(data[i].name, data [i-1].name)<0)
{
tmp= data[i];
j=i-1;
do
{
data [j+1]= data [j];
j--;
}while ((strcmp(, data [j].name)<0&&j>=0));
for(; ;)