2021-01-22

花了两个小时写的通讯录管理系统`#include
#include
#include<conio.h>
using namespace std;
int fanhui();
struct lxr
{
string name;
string xb;
string dh;
string dz;
};
int main()
{
string xh;
string yn;
int y=0;
lxr xinxi[1000];
caidan:
cout<<"\t\t 欢迎使用通讯录管理系统"<<endl;
cout<<"\t\t\t1、添加联系人"<<endl;
cout<<"\t\t\t2、显示联系人"<<endl;
cout<<"\t\t\t3、删除联系人"<<endl;
cout<<"\t\t\t4、查找联系人"<<endl;
cout<<"\t\t\t5、修改联系人"<<endl;
cout<<"\t\t\t6、清空联系人"<<endl;
cout<<"\t\t\t0、退出通讯录"<<endl;
for(;😉
{
if(kbhit())
{
xh=getch();
}
if(xh==“1”)
{
xh="";
goto tianjia;

		}
	if(xh=="2")
	{
		xh="";
		system("cls");
		cout<<"按0返回菜单"<<endl;
		for(int ck=0;1000>ck;ck++)
		{
			if(xinxi[ck].name!="")
			{
				cout<<ck+1<<"、姓名:"
				<<xinxi[ck].name<<"\t性别:"<<xinxi[ck].xb
				<<"\t电话:"<<xinxi[ck].dh<<"\t地址:"<<xinxi[ck].dz<<endl;
				}
			}
	for(;;)
	{
		if(kbhit())
		{
			xh=getch();
			if(xh=="0")
			{
				xh="";
				system("cls");
				goto caidan;
				}
			xh="";
			}
		}
	}
	if(xh=="3")
	{

		xh="";
		system("cls");
		cout<<"请输入你要删除的联系人姓名"<<endl;
		string scmz;
		cin>>scmz;
		for(int i=0;1000>i;i++)
		{
			if(xinxi[i].name==scmz)
			{
				
				xinxi[i].name="";
				xinxi[i].xb="";
				xinxi[i].dh="";
				xinxi[i].dz="";
				cout<<"删除成功,请按任意键返回"<<endl;
				fanhui();
				goto caidan;
				}
			}`
cout<<"该用户不存在,请按任意键返回"<<endl;
			fanhui();
			goto caidan;
			}
		if(xh=="4")
		{
			xh="";
			system("cls");
			cout<<"请输入你要寻找的用户名称"<<endl;
			string name;
			cin>>name;
			for(int yy=0;1000>yy;yy++)
			{
				if(xinxi[yy].name==name)
				{
					cout<<"姓名:"
					<<xinxi[yy].name<<"\t性别:"<<xinxi[yy].xb
					<<"\t电话:"<<xinxi[yy].dh<<"\t地址:"<<xinxi[yy].dz<<endl;
					cout<<"请输入任意键返回"<<endl;
					fanhui();
					goto caidan;
					}
				}
			cout<<"该用户不存在,请输入任意键返回"<<endl;
			fanhui();
			goto caidan;
			}	
		if(xh=="5")
		{
			xh="";
			system("cls");
			cout<<"请输入你即将要修改的用户名称"<<endl;
			string xiugai;
			cin>>xiugai;
			for(int o=0;1000>o;o++)
			{
				if(xinxi[o].name==xiugai)
				{
					cout<<"请输入你要修改的名称"<<endl;
					cin>>xinxi[o].name;
					cout<<"请输入你要修改的性别"<<endl;
					cin>>xinxi[o].xb;
					cout<<"请输入你要修改的电话号码"<<endl;
					cin>>xinxi[o].dh;
					cout<<"请输入你要修改的地址"<<endl;
					cin>>xinxi[o].dz;
					cout<<"修改完毕,请按任意键返回"<<endl;
					fanhui();
					goto caidan;
					}
				}
			cout<<"该用户不存在,请按任意键返回"<<endl;
			fanhui();
			goto caidan;
			
			}	
		if(xh=="6")
		{
			xh="";
			system("cls");
			cout<<"是否确认清除所有数据,清楚后将无法恢复[y/n]"<<endl;
cx:
			cin>>yn;
			if(yn=="y")
			{
				for(int r=0;1000>r;r++)
				{
					xinxi[r].name="";
					xinxi[r].xb="";
					xinxi[r].dh="";
					xinxi[r].dz="";
					
					}
				cout<<"数据已清除完毕,请按任意键返回"<<endl;
				fanhui();
				goto caidan;
				}
			else if(yn=="n")
			{
				goto caidan;
				}
			else
			{
				cout<<"输入有误,请重新输入"<<endl;
				goto cx;
				}
			}
		if(xh=="0")
		{
			xh="";
			system("cls");
			return 1;
			}
		}
tianjia:
    
    for(;1000>y;)
    {
    	system("cls");
    	cout<<"请输入你要录入联系人的姓名"<<endl;
    	cin>>xinxi[y].name;
    	cout<<"请输入你要录入联系人的性别"<<endl;
    	cin>>xinxi[y].xb;
    	cout<<"请输入你要录入联系人的手机号码"<<endl;
    	cin>>xinxi[y].dh;
    	cout<<"请输入你要录入联系人的地址"<<endl;
    	cin>>xinxi[y].dz;
    	y++;
    	cout<<"是否继续录入[y/n]"<<endl;
sfjx:
    	cin>>yn;
    	if(yn=="n")
    	{
    		system("cls");
    		goto caidan;
    		}
    	else if(yn=="y")
    	{
    		system("cls");
    		}
    	else
    	{
    		cout<<"输入有误,请重新输入"<<endl;
    		goto sfjx;
    		}
    	}
	}

int fanhui()
{
	string xh;
	for(;;)
   	{
		if(kbhit())
	  	{
			xh=getch();
			if(xh!="≥" && xh!="")
			{
			xh="";
			system("cls");
			break;
				}
				}
		    	}
	}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值