天天看點

基于C++的學生通訊錄管理系統

這還是大一時候為了完成學校C++軟體設計搞出來的玩意,且看且用吧… …

現在C++離我太遙遠了。

我還記得我是專業第一名,可能是答辯答得好,深得老師歡心的我。

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
using namespace std;
struct record
{
	char name[20];   //姓名
	char phone[12];   //電話
	char adress[50];   //位址
	char postcode[8];   //郵政編碼
	char e_mail[20];   //電子郵件。
	char qq[10];    //QQ号
    char wechat[30];   //微信号 
}student[100];     //假設最大數為100.
//定義全局變量num,表示已經輸入的人數 。
int num;     //這裡使用數組解決通訊錄的問題,實際上使用連結清單更好。
int menu_select()
{
	 char s[80];
	 int a;/*定義整形變量*/
	 system("cls");
	 printf("\t\t\t\t\t*********歡迎進入通訊錄管理界面*********\n");
	 printf("\t\t\t\t\t      |      0. 輸入記錄         |\n");
	 printf("\t\t\t\t\t      |      1. 顯示記錄         |\n");
	 printf("\t\t\t\t\t      |      2. 按姓名查找       |\n");
	 printf("\t\t\t\t\t      |      3. 按電話号碼查找   |\n");
	 printf("\t\t\t\t\t      |      4. 插入記錄         |\n");
	 printf("\t\t\t\t\t      |      5. 按姓名排序       |\n");
	 printf("\t\t\t\t\t      |      6. 删除記錄         |\n");
	 printf("\t\t\t\t\t      |      7. 退出界面         |\n");
	 printf("\t\t\t\t\t     ******************************\n\n");
	do{
			printf("Enter you choice(0~7):");
		    scanf("%s",s);
		    a=atoi(s);
	 }
    while (a<0 || a>7);
    return a;
}
int adduser()
{
	 printf("\t\t\t\t    **************** 請輸入使用者資訊 ****************\n");
	 printf("\t\t\t\t\t輸入姓名:");
	 scanf("%s",student[num].name);
	 printf("\t\t\t\t\t輸入電話号碼:");
	 scanf("%s",student[num].phone);
	 printf("\t\t\t\t\t輸入位址:");
	 scanf("%s",student[num].adress);
	 printf("\t\t\t\t\t輸入郵編:");
	 scanf("%s",student[num].postcode);
	 printf("\t\t\t\t\t輸入e-mail:");
	 scanf("%s",student[num].e_mail);
	 printf("\t\t\t\t\tQQ:");
	 scanf("%s",student[num].qq);
     printf("\t\t\t\t\t輸入微信:");
	 scanf("%s",student[num].wechat);
	 num++;
	 printf("\t\t\t\t\t是否繼續添加?(Y/N):\n");
	 if(getch()=='y' || getch()=='Y')
	     adduser();
	 return(0);
}
void list()
{
	 int i;
	 system("cls");
	 if(num!=0)
	 {
	  printf("\t\t\t\t     *************** 以下為通訊錄所有資訊************\n");
	  for (i=0;i<num;i++)
	  {
	    printf("\t\t\t\t姓名:%s",student[i].name);
		cout<<endl;
		printf("\t\t\t\t電話:%s",student[i].phone);
		cout<<endl;
		printf("\t\t\t\t位址:%s",student[i].adress);
		cout<<endl;
		printf("\t\t\t\t郵編:%s",student[i].postcode);
		cout<<endl;
		printf("\t\t\t\te-mail:%s",student[i].e_mail);
		cout<<endl;
		printf("\t\t\t\tQQ:%s",student[i].qq);
		cout<<endl;
		printf("\t\t\t\t微信:%s",student[i].wechat);
		cout<<endl;
	   if(i+1<num)
	   {
		system("pause");
	   }
	  }
	  printf("\t\t\t\t*******************************************************\n");
	 }
	 else
	  printf("\t\t\t\t\t  ********通訊錄中無任何紀錄********\n");
	  printf("按任意鍵傳回主菜單:");
	  getch();    //這裡是無回顯的輸入字元,你輸入的字元不會顯示在螢幕上。
	  return;
}
int searchbyname()
{
	 int mark=0;
	 int i;
	 printf("\t\t\t\t***************** 按姓名查找 *******************\n");
	 char name[20];
	 printf("\t\t\t請輸入姓名:");
	 scanf("%s",name);
	 for(i=0;i<num;i++)
	 {
		  if (strcmp(student[i].name,name)==0)
		   {
			printf("\t\t\t\t************* 以下是您查找的使用者資訊 ***********\n");
			printf("\t\t\t\t姓名: %s",student[i].name);
			cout<<endl;
			printf("\t\t\t\t電話: %s",student[i].phone);
			cout<<endl;
			printf("\t\t\t\t位址: %s",student[i].adress);
			cout<<endl;
			printf("\t\t\t\te-mail:%s",student[i].e_mail);
			cout<<endl;
			printf("\t\t\t\t郵編:%s",student[i].postcode);
			cout<<endl;
			printf("\t\t\t\tQQ:%s",student[i].qq);
			cout<<endl;
			printf("\t\t\t\t微信:%s",student[i].wechat);
			cout<<endl;
			printf("\t\t\t\t\t\t\t\t\t************************************************\n");
			mark++;
		   if((i+1)<num)
		   {
			   printf("\t\t\t\t是否繼續查找相同名字的使用者資訊:(y/n)\n");
			   if(getch()=='y' || getch()=='Y')
			   {
					 continue;
			   }
			   else
					 return(0);
		   }
		   else
		   {
			   printf("按任意鍵傳回主菜單:");
			   getch();
			   return(0);
		   }
		  }
	 }
	 if(mark == 0)
	 {
		  printf("\t\t\t\t沒有相同姓名的使用者紀錄\n");
		  printf("按任意鍵傳回主菜單:");
		  getch();
		  return(0);
	 }
	 return 0;
}
int searchbyphone()
{
	int mark=0;
	int i;
	printf("\t\t\t\t****************** 按電話查找 ******************\n");
	char phone[10];
	printf("\t\t\t\t請輸入電話号碼:");
	scanf("%s",phone);
	for(i=0;i<num;i++)
	{
	 if (strcmp(student[i].phone,phone)==0)
	 {
	  printf("\t\t\t\t************** 以下是您查找的使用者資訊 **********\n");
	  printf("\t\t\t\t姓名: %s",student[i].name);
	  cout<<endl;
	  printf("\t\t\t\t電話: %s",student[i].phone);
	  cout<<endl;
	  printf("\t\t\t\t位址: %s",student[i].adress);
	  cout<<endl;
	  printf("\t\t\t\te-mail:%s",student[i].e_mail);
	  cout<<endl;
	  printf("\t\t\t\t郵編:%s",student[i].postcode);
	  cout<<endl; 
	  printf("\t\t\t\tQQ:%s",student[i].qq);
	  cout<<endl;
	  printf("\t\t\t\t微信:%s",student[i].wechat);
	  cout<<endl;
	  printf("\t\t\t\t************************************************\n");
	  printf("按任意鍵傳回主菜單:");
	  mark++;
	  getch();
	  return(0);
	 }
	}
	if (mark==0)
	{
	 printf("\t\t\t\t沒有改使用者的資訊\n");
	 printf("按任意鍵傳回主菜單:");
	 getch();
	 return(0);
	}
	return(0);
}
void deletebyphone()
{
	int i,j;
	int deletemark=0;
	char phone[20];
	 cout<<endl;
	 printf("\t\t\t\t請輸入要删除使用者電話号碼:");
	 scanf("%s",phone);
	 if(num==0)
	 {
	  printf("\t\t\t\t對不起,檔案中無任何紀錄\n");
	  printf("按任意鍵傳回主菜單:");
	  getch();
	 return;
	 }
	 for (i=0;i<num;i++)
	 {    if (strcmp(student[i].phone,phone)==0)
		  {
			  printf("\t\t\t\t以下是您要删除的使用者紀錄:\n");
			  printf("\t\t\t\t姓名: %s",student[i].name);
			  cout<<endl;
			  printf("\t\t\t\t電話: %s",student[i].phone);
			  cout<<endl;
			  printf("\t\t\t\t位址: %s",student[i].adress);
			  cout<<endl;
			  printf("\t\t\t\te-mail:%s",student[i].e_mail);
			  cout<<endl;
			  printf("\t\t\t\t郵編:%s",student[i].postcode);
			  cout<<endl;
			  printf("\t\t\t\tQQ:%s",student[i].qq);
			  cout<<endl;
			  printf("\t\t\t\t微信:%s",student[i].wechat);
              cout<<endl;
			  printf("\t\t\t\t是否删除?(y/n)");
			  if (getch()=='y' || getch()=='Y')
			  {    for (j=i;j<num-1;j++)
				        student[j]=student[j+1];
                   num--;
				   deletemark++;
				   printf("\t\t\t\t删除成功\n");
				   printf("\t\t\t\t是否繼續删除?(y/n)");
				   if (getch()=='y' || getch()=='Y')
				        deletebyphone();
				   return;
			  }
			  else
			  return;
		  }
		 continue;
	 }
	 if (deletemark==0)
	 {
		  printf("\t\t\t\t沒有該使用者的紀錄\n");
		  printf("\t\t\t\t是否繼續删除?(y/n)");
		  if(getch()=='y' || getch()=='Y')
		        deletebyphone();
		  return;
     }
	 return;
}
void deletebyname()
{
	int a=0;
	int findmark=0;
	int j;
	int deletemark=0;
	int i;
	char name[20];
	cout<<endl;
	printf("請輸入要删除使用者姓名:");
	scanf("%s",name);
	for (i=a;i<num;i++)
	{
	 if(strcmp(student[i].name,name)==0)
	 {
	  printf("\t\t\t\t以下是您要删除的使用者紀錄:\n");
	  findmark++;
	  printf("\t\t\t\t________________________________\n");
	  printf("\t\t\t\t姓名: %s",student[i].name);
	  cout<<endl;
	  printf("\t\t\t\t電話: %s",student[i].phone);
	  cout<<endl;
	  printf("\t\t\t\t位址: %s",student[i].adress);
	  cout<<endl;
	  printf("\t\t\t\te-mail:%s",student[i].e_mail);
	  cout<<endl;
	  printf("\t\t\t\t郵編:%s",student[i].postcode); 
	  cout<<endl; 
	  printf("\t\t\t\tQQ:%s",student[i].qq);
	  cout<<endl;
	  printf("\t\t\t\t微信:%s",student[i].wechat);
	  cout<<endl;
	  printf("\t\t\t\t________________________________\n");
	  cout<<endl;
	  printf("\t\t\t\t是否删除?(y/n)");
	  if (getch()=='y' || getch() == 'Y')
	  {
	  for(j=i;j<num-1;j++)
	   student[j]=student[j+1];
	  num--;
	  deletemark++;
	  printf("\t\t\t\t删除成功\n");
	  if((i+1)<num)
	  {
	   printf("\t\t\t\t是否繼續删除相同姓名的使用者資訊?(y/n)");
	   if (getch()=='y')
	   {
		a=i;
	   continue;
	   }
	  }
	   printf("\t\t\t\t是否繼續删除?(y/n)");
	  if (getch()=='y')
	   deletebyname();
	  return;
	  }
	  if((i+1)<num)
	  {
	   printf("\t\t\t\t是否繼續删除相同姓名的使用者資訊?(y/n)");
	   if (getch()=='y' || getch() == 'Y')
	   {a=i;
	    continue;}
	  }
	 }
	else
	continue;
	}
	if ((deletemark==0)&&(findmark==0))
	{
	 printf("\t\t\t\t沒有該使用者的紀錄\n");
	 printf("\t\t\t\t是否繼續删除?(y/n)");
	 if(getch()=='y' || getch() == 'Y')
	   deletebyphone();
	 return;
	}
	else if (findmark!=0)
	{
	 printf("\t\t\t\t沒有重名資訊\n");
	 printf("\t\t\t\t沒有該使用者的紀錄\n");
	 printf("\t\t\t\t是否繼續删除?(y/n)");
	 if(getch()=='y' || getch() == 'Y')
	  deletebyphone();
	 return;
	 }
	}
int dele()
{
	char choic;
	 printf("\t\t\t\t1-按電話号碼删除 2-按姓名删除\n");
	 printf("\t\t\t\t請選擇:");
	 choic=getch();
	switch (choic)
	{case '1':deletebyphone();break;
	 case '2':deletebyname();break;}
	 return(0);
}
int sortbyname()   //按姓名進行排序
{
	 int i,j;
	 struct record tmp;
	 for (i=1;i<num;i++)
	 {
	 if(strcmp(student[i].name,student[i-1].name)<0)
	 {
	  tmp=student[i];
	  j=i-1;
	  do
	  {student[j+1]=student[j];
	   j--;
	  }while ((strcmp(tmp.name,student[j].name)<0&&j>=0));
	  student[j+1]=tmp;}
	 }
	 cout<<endl;
	 printf("\t\t\t\t排序成功,是否顯示?(y/n)");
	 if (getch()=='y')
	  list();
	 return(0);
}
int main()
{system("color 75");
    printf("\t\t                  ***************************************************\n");
    printf("\t\t                                 \n");
    printf("\t\t                       ★★★★★★歡迎使用通訊錄系統 ★★★★★★\n");
    printf("\t\t                                 \n");
    printf("\t\t                             ###########制作人###########\n");
    printf("\t\t                                 \n");
    printf("\t\t                                  羅志偉 肖麗萍 劉蝶\n");
    printf("\t\t                                 \n");
    printf("\t\t                         江西理工大學資訊工程學院通信工程162班");
    printf("\t\t                                 \n");
    printf("\t\t                                 \n");
    printf("\t\t                                 \n");
    printf("\t\t                                 \n");
    printf("                                                  按任意鍵進入主菜單:");
getch();
int selectnum;
    while(1)
    {
    	selectnum = menu_select();
    	switch(selectnum)
    	{
case 0:
			{adduser();
			 break;}
case 1:
			{list();
             break;}
case 2:
			{searchbyname();
             break;}
case 3:
			{searchbyphone();
             break;}
case 4:
			{adduser();//這裡插入,應該能指定位置,不過意義不大,是以和添加記錄一樣了。
             break;}
case 5:
			{sortbyname();
             break;}
case 6:
			{dele();
             break;}
case 7:
			{printf("BYE BYE!\n");
			 system("pause");
			 getchar();
             exit(0);}
    	}
    }
    getchar();
    return 0;
}
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
using namespace std;
struct record
{
	char name[20];   //姓名
	char phone[12];   //電話
	char adress[50];   //位址
	char postcode[8];   //郵政編碼
	char e_mail[20];   //電子郵件。
	char qq[10];    //QQ号
    char wechat[30];   //微信号 
}student[100];     //假設最大數為100.
//定義全局變量num,表示已經輸入的人數 。
int num;     //這裡使用數組解決通訊錄的問題,實際上使用連結清單更好。
int menu_select()
{
	 char s[80];
	 int a;/*定義整形變量*/
	 system("cls");
	 printf("\t\t\t\t\t*********歡迎進入通訊錄管理界面*********\n");
	 printf("\t\t\t\t\t      |      0. 輸入記錄         |\n");
	 printf("\t\t\t\t\t      |      1. 顯示記錄         |\n");
	 printf("\t\t\t\t\t      |      2. 按姓名查找       |\n");
	 printf("\t\t\t\t\t      |      3. 按電話号碼查找   |\n");
	 printf("\t\t\t\t\t      |      4. 插入記錄         |\n");
	 printf("\t\t\t\t\t      |      5. 按姓名排序       |\n");
	 printf("\t\t\t\t\t      |      6. 删除記錄         |\n");
	 printf("\t\t\t\t\t      |      7. 退出界面         |\n");
	 printf("\t\t\t\t\t     ******************************\n\n");
	do{
			printf("Enter you choice(0~7):");
		    scanf("%s",s);
		    a=atoi(s);
	 }
    while (a<0 || a>7);
    return a;
}
int adduser()
{
	 printf("\t\t\t\t    **************** 請輸入使用者資訊 ****************\n");
	 printf("\t\t\t\t\t輸入姓名:");
	 scanf("%s",student[num].name);
	 printf("\t\t\t\t\t輸入電話号碼:");
	 scanf("%s",student[num].phone);
	 printf("\t\t\t\t\t輸入位址:");
	 scanf("%s",student[num].adress);
	 printf("\t\t\t\t\t輸入郵編:");
	 scanf("%s",student[num].postcode);
	 printf("\t\t\t\t\t輸入e-mail:");
	 scanf("%s",student[num].e_mail);
	 printf("\t\t\t\t\tQQ:");
	 scanf("%s",student[num].qq);
     printf("\t\t\t\t\t輸入微信:");
	 scanf("%s",student[num].wechat);
	 num++;
	 printf("\t\t\t\t\t是否繼續添加?(Y/N):\n");
	 if(getch()=='y' || getch()=='Y')
	     adduser();
	 return(0);
}
void list()
{
	 int i;
	 system("cls");
	 if(num!=0)
	 {
	  printf("\t\t\t\t     *************** 以下為通訊錄所有資訊************\n");
	  for (i=0;i<num;i++)
	  {
	    printf("\t\t\t\t姓名:%s",student[i].name);
		cout<<endl;
		printf("\t\t\t\t電話:%s",student[i].phone);
		cout<<endl;
		printf("\t\t\t\t位址:%s",student[i].adress);
		cout<<endl;
		printf("\t\t\t\t郵編:%s",student[i].postcode);
		cout<<endl;
		printf("\t\t\t\te-mail:%s",student[i].e_mail);
		cout<<endl;
		printf("\t\t\t\tQQ:%s",student[i].qq);
		cout<<endl;
		printf("\t\t\t\t微信:%s",student[i].wechat);
		cout<<endl;
	   if(i+1<num)
	   {
		system("pause");
	   }
	  }
	  printf("\t\t\t\t*******************************************************\n");
	 }
	 else
	  printf("\t\t\t\t\t  ********通訊錄中無任何紀錄********\n");
	  printf("按任意鍵傳回主菜單:");
	  getch();    //這裡是無回顯的輸入字元,你輸入的字元不會顯示在螢幕上。
	  return;
}
int searchbyname()
{
	 int mark=0;
	 int i;
	 printf("\t\t\t\t***************** 按姓名查找 *******************\n");
	 char name[20];
	 printf("\t\t\t請輸入姓名:");
	 scanf("%s",name);
	 for(i=0;i<num;i++)
	 {
		  if (strcmp(student[i].name,name)==0)
		   {
			printf("\t\t\t\t************* 以下是您查找的使用者資訊 ***********\n");
			printf("\t\t\t\t姓名: %s",student[i].name);
			cout<<endl;
			printf("\t\t\t\t電話: %s",student[i].phone);
			cout<<endl;
			printf("\t\t\t\t位址: %s",student[i].adress);
			cout<<endl;
			printf("\t\t\t\te-mail:%s",student[i].e_mail);
			cout<<endl;
			printf("\t\t\t\t郵編:%s",student[i].postcode);
			cout<<endl;
			printf("\t\t\t\tQQ:%s",student[i].qq);
			cout<<endl;
			printf("\t\t\t\t微信:%s",student[i].wechat);
			cout<<endl;
			printf("\t\t\t\t\t\t\t\t\t************************************************\n");
			mark++;
		   if((i+1)<num)
		   {
			   printf("\t\t\t\t是否繼續查找相同名字的使用者資訊:(y/n)\n");
			   if(getch()=='y' || getch()=='Y')
			   {
					 continue;
			   }
			   else
					 return(0);
		   }
		   else
		   {
			   printf("按任意鍵傳回主菜單:");
			   getch();
			   return(0);
		   }
		  }
	 }
	 if(mark == 0)
	 {
		  printf("\t\t\t\t沒有相同姓名的使用者紀錄\n");
		  printf("按任意鍵傳回主菜單:");
		  getch();
		  return(0);
	 }
	 return 0;
}
int searchbyphone()
{
	int mark=0;
	int i;
	printf("\t\t\t\t****************** 按電話查找 ******************\n");
	char phone[10];
	printf("\t\t\t\t請輸入電話号碼:");
	scanf("%s",phone);
	for(i=0;i<num;i++)
	{
	 if (strcmp(student[i].phone,phone)==0)
	 {
	  printf("\t\t\t\t************** 以下是您查找的使用者資訊 **********\n");
	  printf("\t\t\t\t姓名: %s",student[i].name);
	  cout<<endl;
	  printf("\t\t\t\t電話: %s",student[i].phone);
	  cout<<endl;
	  printf("\t\t\t\t位址: %s",student[i].adress);
	  cout<<endl;
	  printf("\t\t\t\te-mail:%s",student[i].e_mail);
	  cout<<endl;
	  printf("\t\t\t\t郵編:%s",student[i].postcode);
	  cout<<endl; 
	  printf("\t\t\t\tQQ:%s",student[i].qq);
	  cout<<endl;
	  printf("\t\t\t\t微信:%s",student[i].wechat);
	  cout<<endl;
	  printf("\t\t\t\t************************************************\n");
	  printf("按任意鍵傳回主菜單:");
	  mark++;
	  getch();
	  return(0);
	 }
	}
	if (mark==0)
	{
	 printf("\t\t\t\t沒有改使用者的資訊\n");
	 printf("按任意鍵傳回主菜單:");
	 getch();
	 return(0);
	}
	return(0);
}
void deletebyphone()
{
	int i,j;
	int deletemark=0;
	char phone[20];
	 cout<<endl;
	 printf("\t\t\t\t請輸入要删除使用者電話号碼:");
	 scanf("%s",phone);
	 if(num==0)
	 {
	  printf("\t\t\t\t對不起,檔案中無任何紀錄\n");
	  printf("按任意鍵傳回主菜單:");
	  getch();
	 return;
	 }
	 for (i=0;i<num;i++)
	 {    if (strcmp(student[i].phone,phone)==0)
		  {
			  printf("\t\t\t\t以下是您要删除的使用者紀錄:\n");
			  printf("\t\t\t\t姓名: %s",student[i].name);
			  cout<<endl;
			  printf("\t\t\t\t電話: %s",student[i].phone);
			  cout<<endl;
			  printf("\t\t\t\t位址: %s",student[i].adress);
			  cout<<endl;
			  printf("\t\t\t\te-mail:%s",student[i].e_mail);
			  cout<<endl;
			  printf("\t\t\t\t郵編:%s",student[i].postcode);
			  cout<<endl;
			  printf("\t\t\t\tQQ:%s",student[i].qq);
			  cout<<endl;
			  printf("\t\t\t\t微信:%s",student[i].wechat);
              cout<<endl;
			  printf("\t\t\t\t是否删除?(y/n)");
			  if (getch()=='y' || getch()=='Y')
			  {    for (j=i;j<num-1;j++)
				        student[j]=student[j+1];
                   num--;
				   deletemark++;
				   printf("\t\t\t\t删除成功\n");
				   printf("\t\t\t\t是否繼續删除?(y/n)");
				   if (getch()=='y' || getch()=='Y')
				        deletebyphone();
				   return;
			  }
			  else
			  return;
		  }
		 continue;
	 }
	 if (deletemark==0)
	 {
		  printf("\t\t\t\t沒有該使用者的紀錄\n");
		  printf("\t\t\t\t是否繼續删除?(y/n)");
		  if(getch()=='y' || getch()=='Y')
		        deletebyphone();
		  return;
     }
	 return;
}
void deletebyname()
{
	int a=0;
	int findmark=0;
	int j;
	int deletemark=0;
	int i;
	char name[20];
	cout<<endl;
	printf("請輸入要删除使用者姓名:");
	scanf("%s",name);
	for (i=a;i<num;i++)
	{
	 if(strcmp(student[i].name,name)==0)
	 {
	  printf("\t\t\t\t以下是您要删除的使用者紀錄:\n");
	  findmark++;
	  printf("\t\t\t\t________________________________\n");
	  printf("\t\t\t\t姓名: %s",student[i].name);
	  cout<<endl;
	  printf("\t\t\t\t電話: %s",student[i].phone);
	  cout<<endl;
	  printf("\t\t\t\t位址: %s",student[i].adress);
	  cout<<endl;
	  printf("\t\t\t\te-mail:%s",student[i].e_mail);
	  cout<<endl;
	  printf("\t\t\t\t郵編:%s",student[i].postcode); 
	  cout<<endl; 
	  printf("\t\t\t\tQQ:%s",student[i].qq);
	  cout<<endl;
	  printf("\t\t\t\t微信:%s",student[i].wechat);
	  cout<<endl;
	  printf("\t\t\t\t________________________________\n");
	  cout<<endl;
	  printf("\t\t\t\t是否删除?(y/n)");
	  if (getch()=='y' || getch() == 'Y')
	  {
	  for(j=i;j<num-1;j++)
	   student[j]=student[j+1];
	  num--;
	  deletemark++;
	  printf("\t\t\t\t删除成功\n");
	  if((i+1)<num)
	  {
	   printf("\t\t\t\t是否繼續删除相同姓名的使用者資訊?(y/n)");
	   if (getch()=='y')
	   {
		a=i;
	   continue;
	   }
	  }
	   printf("\t\t\t\t是否繼續删除?(y/n)");
	  if (getch()=='y')
	   deletebyname();
	  return;
	  }
	  if((i+1)<num)
	  {
	   printf("\t\t\t\t是否繼續删除相同姓名的使用者資訊?(y/n)");
	   if (getch()=='y' || getch() == 'Y')
	   {a=i;
	    continue;}
	  }
	 }
	else
	continue;
	}
	if ((deletemark==0)&&(findmark==0))
	{
	 printf("\t\t\t\t沒有該使用者的紀錄\n");
	 printf("\t\t\t\t是否繼續删除?(y/n)");
	 if(getch()=='y' || getch() == 'Y')
	   deletebyphone();
	 return;
	}
	else if (findmark!=0)
	{
	 printf("\t\t\t\t沒有重名資訊\n");
	 printf("\t\t\t\t沒有該使用者的紀錄\n");
	 printf("\t\t\t\t是否繼續删除?(y/n)");
	 if(getch()=='y' || getch() == 'Y')
	  deletebyphone();
	 return;
	 }
	}
int dele()
{
	char choic;
	 printf("\t\t\t\t1-按電話号碼删除 2-按姓名删除\n");
	 printf("\t\t\t\t請選擇:");
	 choic=getch();
	switch (choic)
	{case '1':deletebyphone();break;
	 case '2':deletebyname();break;}
	 return(0);
}
int sortbyname()   //按姓名進行排序
{
	 int i,j;
	 struct record tmp;
	 for (i=1;i<num;i++)
	 {
	 if(strcmp(student[i].name,student[i-1].name)<0)
	 {
	  tmp=student[i];
	  j=i-1;
	  do
	  {student[j+1]=student[j];
	   j--;
	  }while ((strcmp(tmp.name,student[j].name)<0&&j>=0));
	  student[j+1]=tmp;}
	 }
	 cout<<endl;
	 printf("\t\t\t\t排序成功,是否顯示?(y/n)");
	 if (getch()=='y')
	  list();
	 return(0);
}
int main()
{system("color 75");
    printf("\t\t                  ***************************************************\n");
    printf("\t\t                                 \n");
    printf("\t\t                       ★★★★★★歡迎使用通訊錄系統 ★★★★★★\n");
    printf("\t\t                                 \n");
    printf("\t\t                             ###########制作人###########\n");
    printf("\t\t                                 \n");
    printf("\t\t                                  羅志偉 肖麗萍 劉蝶\n");
    printf("\t\t                                 \n");
    printf("\t\t                         江西理工大學資訊工程學院通信工程162班");
    printf("\t\t                                 \n");
    printf("\t\t                                 \n");
    printf("\t\t                                 \n");
    printf("\t\t                                 \n");
    printf("                                                  按任意鍵進入主菜單:");
getch();
int selectnum;
    while(1)
    {
    	selectnum = menu_select();
    	switch(selectnum)
    	{
case 0:
			{adduser();
			 break;}
case 1:
			{list();
             break;}
case 2:
			{searchbyname();
             break;}
case 3:
			{searchbyphone();
             break;}
case 4:
			{adduser();//這裡插入,應該能指定位置,不過意義不大,是以和添加記錄一樣了。
             break;}
case 5:
			{sortbyname();
             break;}
case 6:
			{dele();
             break;}
case 7:
			{printf("BYE BYE!\n");
			 system("pause");
			 getchar();
             exit(0);}
    	}
    }
    getchar();
    return 0;
}