#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <windows.h>
using namespace std;
struct Client
{
string name;
int Phone;
struct Client *Next;
};
struct Business
{
string BusinessName;
Client *ClientHead;
struct Business *Next;
};
int main()
{
Client *ClientMove;
Business *BusinessHead=new Business,*BusinessMove;
BusinessMove=BusinessHead;
int i,num=0;
cout<<"输入要添加的业务个数:"<<endl;cin>>i;
while(num<i)
{
num++;
cout<<"请输入第 "<<num<<"个业务名称:"<<endl;Business *BusinessData=new Busines;
cin>>BusinessData->BusinessName;
BusinessData->ClientHead=new Client;
BusinessData->ClientHead->Next=nullptr;
BusinessMove->Next=BusinessData;
BusinessMove=BusinessData;
}
BusinessMove->Next=nullptr;
cout<<"业务显示:"<<endl;
int num1=1;
BusinessMove=BusinessHead;
while(BusinessMove->Next!=nullptr)
{
BusinessMove=BusinessMove->Next;
cout<<"第 "<<num1<<" 业务是:"<<BusinessMove->BusinessName<<endl;
num1++;
}
cout<<endl;
//*****************************
string strname;
cout<<"请输入要添加客户的业务名称:"<<endl;cin>>strname;
BusinessMove=BusinessHead;
while(BusinessMove->Next!=nullptr)
{
BusinessMove=BusinessMove->Next;
if(BusinessMove->BusinessName==strname)
{
cout<<"你要添加客户的业务名称是:"<<BusinessMove->BusinessName<<endl;
ClientMove=BusinessMove->ClientHead;
break;
}
}
int num2,count=0;
cout<<"请输入要添加客户的个数:"<<endl;
cin>>num2;
while(count<num2)
{
count++;
Client *ClientData=new Client;
cout<<"请输入第"<<count<<"客户的姓名,电话:"<<endl;
cin>>ClientData->name>>ClientData->Phone;
ClientMove->Next=ClientData;
ClientMove=ClientData;
}
ClientMove->Next=nullptr;
cout<<"客户输入完毕"<<endl;
//******************
cout<<"输入全部信息:"<<endl;
BusinessMove=BusinessHead;
int num3=1,num4=0;
BusinessMove=BusinessHead;
while(BusinessMove->Next!=nullptr)
{
BusinessMove=BusinessMove->Next;
cout<<"第 "<<num3<<" 业务是:"<<BusinessMove->BusinessName<<endl;
ClientMove=BusinessMove->ClientHead;
while(ClientMove->Next!=nullptr)
{
num4++;
ClientMove=ClientMove->Next;
cout<<setw(4)<<"第"<<num4<<"个客户信息:";
cout<<setw(14)<<ClientMove->name<<setw(13)<<ClientMove->Phone<<endl;
}
num3++;
}
cout<<endl;
system("pause");
return 0;
}