经过数据结构实训,我第一次一个人写出了1000多行的代码,对自己也是一个挑战吧
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <cstring>
#include <windows.h>
#include <stack>
#include <queue>
using namespace std;
//定义一个主菜单操作员显示类,供操作员登陆管理
class MainMenu
{
public:
void ShowMain();
} MainMenu1;
void MainMenu::ShowMain()
{
cout<<"\t┏═══════════════════════════┓"<<endl;
cout<<"\t┃ ┃★★欢迎进入汽车销售管理系统★★┃ ┃"<<endl;
cout<<"\t┠═══════════════════════════┨"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★1 操作员登陆 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┗═══════════════════════════┛"<<endl;
}
//定义一个操作员管理类,以便系统安全运行
class OperatorMain
{
public:
void OperatorShow();
} OperatorMain1;
void OperatorMain::OperatorShow()
{
cout<<"\t┏═══════════════════════════┓"<<endl;
cout<<"\t┃ ┃★★欢迎进入汽车销售管理系统★★┃ ┃"<<endl;
cout<<"\t┠═══════════════════════════┨"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★1 用户管理 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★2 车辆采购管理 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★3 车辆销售管理 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★4 车辆库存管理 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ 请按数字键选择(数字0退出) ┃"<<endl;
cout<<"\t┗═══════════════════════════┛"<<endl;
}
//定义一个操作员信息的验证类,声明它的私有成员和公用成员,以便系统安全运行
class Operator
{
private:
string OperatorName;
string OperatorMima;
string Name;
string Mima;
public:
Operator()//定义构造函数,数据的初始化
{
OperatorName="admin";
OperatorMima="123456";
}
void Cin();
void Cout();
} Operator1;
void Operator::Cin()
{
cout<<"\t\t请正确输入操作员的姓名:"<<endl;
cin>>Name;
cout<<"\t\t请正确输入操作员的密码:"<<endl;
cin>>Mima;
}
void Operator::Cout()
{
if(Name=="admin" && Mima=="123456")
{
cout<<"\t登陆成功!"<<endl;
cout<<"\t请执行以下操作:"<<endl;
}
else
{
cout<<"\t输入错误"<<endl;
cout<<"\t系统处于崩溃状态,请重新进行操作!"<<endl;
Sleep(100000000);
system("cls");
}
}
//定义用户信息类
class User
{
//使用链表的第一步:创建类 保存数据long
public:
//数据域,用来记录数据
string UserName;//用户姓名
char UserSex;//用户性别
int UserAge;//用户年龄
long UserNumber;//用户客户号
string UserAddress;//用户地址
string UserLink;//用户联系方式
//指着域,用来记录它下一个节点的地址
//访问这个变量能找到它的下一个节点
User *next;
void UserAdd(User *head1,User *move1,User *temp1);
void UserDel(User *head1,User *move1,User *temp1);
void UserChange(User *head1,User *move1,User *temp1);
void UserFind(User *head1,User *move1,User *temp1);
void UserInsert(User *head1,User *move1,User *temp1);
} User1;
//使用链表的第二步:创建三个指针 备用
//User *head1,*move1,*temp1;
//使用链表的第三步:创建节点
User *head1=new User;
//用户信息的增删改查
void User::UserAdd(User *head1,User *move1,User *temp1)
{
cout<<"请输入有几个用户:"<<endl;
int n =0;
cin>>n;
for(int i=0; i<n; i++)
{
//给节点赋值
cout<<"请输入第"<<i+1<<"个用户的姓名:"<<endl;;
cin>>move1->UserName;
//给节点赋值
cout<<"请输入第"<<i+1<<"个用户的性别:"<<endl;;
cin>>move1->UserSex;
//给节点赋值
cout<<"请输入第"<<i+1<<"个用户的年龄:"<<endl;;
cin>>move1->UserAge;
//给节点赋值
cout<<"请输入第"<<i+1<<"个用户的客户号:"<<endl;;
cin>>move1->UserNumber;
//给节点赋值
cout<<"请输入第"<<i+1<<"个用户的地址:"<<endl;;
cin>>move1->UserAddress;
//给节点赋值
cout<<"请输入第"<<i+1<<"个用户的联系方式:"<<endl;;
cin>>move1->UserLink;
//--------
//这里就是链表连接的关键代码
//先移动temp1指针
temp1=move1;
User *move1=new User;
temp1->next=move1;
}
//这里注意链表规定 最后节点的next一定要指向NULL
temp1=move1;
temp1->next=NULL;
//个人习惯
move1=head1;
}
void User::UserDel(User *head1,User *move1,User *temp1)
{
cout<<"请输入要删除的客户号:"<<endl;
long Number=0;
cin>>Number;
if(head1->UserNumber==Number)
{
head1=head1->next;
free(head1);
cout<<"成功删除用户!"<<endl;
}
else
{
while(move1->next!=NULL)
{
if(move1->UserNumber==Number)
{
temp1->next=move1->next;
free(move1);
cout<<"成功删除用户!"<<endl;
break;
}
temp1=move1;
move1=move1->next;
}
}
move1=head1;
}
void User::UserChange(User *head1,User *move1,User *temp1)
{
cout<<"请输入要修改的用户的客户号:"<<endl;
long Number=0;
cin>>Number;
while(move1->next!=NULL)
{
if(move1->UserNumber==Number)
{
//给节点重新赋值
cout<<"请输入用户的客户号:"<<endl;
cin>>move1->UserNumber;
//给节点重新赋值
cout<<"请输入用户的姓名:"<<endl;
cin>>move1->UserName;
//给节点重新赋值
cout<<"请输入用户的性别:"<<endl;
cin>>move1->UserSex;
//给节点重新赋值
cout<<"请输入用户的年龄:"<<endl;
cin>>move1->UserAge;
//给节点重新赋值
cout<<"请输入用户的地址:"<<endl;
cin>>move1->UserAddress;
//给节点重新赋值
cout<<"请输入用户的联系方式:"<<endl;
cin>>move1->UserLink;
}
move1=move1->next;
}
move1=head1;
}
void User::UserFind(User *head1,User *move1,User *temp1)
{
cout<<"请输入要查找的用户的客户号:"<<endl;
long Number=0;
cin>>Number;
while(move1->next!=NULL)
{
if(move1->UserNumber==Number)
{
cout<<"成功查找到用户!"<<endl;
}
move1=move1->next;
}
move1=head1;
}
void User::UserInsert(User *head1,User *move1,User *temp1)
{
cout<<"请输入要在哪个用户的客户号后面插入:"<<endl;
long Number=0;
cin>>Number;
while(move1->next!=NULL)
{
if(move1->UserNumber==Number)
{
User *temp1 = new User;
cout<<"请输入用户的客户号:"<<endl;
cin>>move1->UserNumber;
//给节点赋值
cout<<"请输入用户的姓名:"<<endl;
cin>>move1->UserName;
//给节点赋值
cout<<"请输入用户的性别:"<<endl;
cin>>move1->UserSex;
//给节点重新赋值
cout<<"请输入用户的年龄:"<<endl;
cin>>move1->UserAge;
//给节点重新赋值
cout<<"请输入用户的地址:"<<endl;
cin>>move1->UserAddress;
//给节点重新赋值
cout<<"请输入用户的联系方式:"<<endl;
cin>>move1->UserLink;
//----
temp1->next=move1->next;
move1->next=temp1;
}
move1=move1->next;
}
temp1=move1;
temp1->next=NULL;
move1=head1;
}
class UserInfor
{
public:
void ShowInfor();
} UserInfor1;
void UserInfor::ShowInfor()
{
cout<<"\t┠═══════════════════════════┨"<<endl;
cout<<"\t┃ ★1 用户信息的添加 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★2 用户信息的删除 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★3 用户信息的修改 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★4 用户信息的查找 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★5 用户信息的插入 ┃"<<endl;
cout<<"\t┗═══════════════════════════┛"<<endl;
}
//定义一个车辆采购类,以便操作员对车辆进行添加
class CarPurchase
{
//使用链表的第一步:创建类 保存数据
public:
//数据域,用来记录数据
long Purchase_Number;//采购订单号
string Purchase_Date;//采购日期
long Firm_Num;//厂商编号
string Firm_Name;//厂商名称
string Link_Man;//联系人
string Link_Num;//联系电话
string Zip_Code;//邮政编码
string Mail_Address;//通信地址
string Car_Code;//车型代码
string Car_Type;//车辆类型
string Brand_Type;//厂牌型号
string Produce_Area;//产地
string Purchase_price;//采购单价
string Sale_Man;//业务员
string Produce_Man;//制单员
//指着域,用来记录它下一个节点的地址
//访问这个变量能找到它的下一个节点
CarPurchase *next;
void CarPurchaseAdd(CarPurchase *head2,CarPurchase *move2,CarPurchase *temp2);
void CarPurchaseDel(CarPurchase *head2,CarPurchase *move2,CarPurchase *temp2);
void CarPurchaseChange(CarPurchase *head2,CarPurchase *move2,CarPurchase *temp2);
void CarPurchaseFind(CarPurchase *head2,CarPurchase *move2,CarPurchase *temp2);
void CarPurchaseInsert(CarPurchase *head2,CarPurchase *move2,CarPurchase *temp2);
} CarPurchase1;
//使用链表的第二步:创建三个指针 备用
//User *head1,*move1,*temp1;
//使用链表的第三步:创建节点
CarPurchase *head2=new CarPurchase;
void CarPurchase::CarPurchaseAdd(CarPurchase *head2,CarPurchase *move2,CarPurchase *temp2)
{
cout<<"请输入汽车的数量:"<<endl;
int n =0;
cin>>n;
for(int i=0; i<n; i++)
{
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的采购订单号:"<<endl;;
cin>>move2->Purchase_Number;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的采购日期:"<<endl;;
cin>>move2->Purchase_Date;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的厂商编号:"<<endl;;
cin>>move2->Firm_Num;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的厂商名称:"<<endl;;
cin>>move2->Firm_Name;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的联系人:"<<endl;;
cin>>move2->Link_Man;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的联系电话:"<<endl;;
cin>>move2->Link_Num;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的邮政编码:"<<endl;;
cin>>move2->Zip_Code;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的通信地址:"<<endl;;
cin>>move2->Mail_Address;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的车型代码:"<<endl;;
cin>>move2->Car_Code;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的车辆类型:"<<endl;;
cin>>move2->Car_Type;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的厂牌型号:"<<endl;;
cin>>move2->Brand_Type;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的产地:"<<endl;;
cin>>move2->Produce_Area;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的采购单价:"<<endl;;
cin>>move2->Purchase_price;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的业务员:"<<endl;;
cin>>move2->Sale_Man;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的制单员:"<<endl;;
cin>>move2->Produce_Man;
//--------
//这里就是链表连接的关键代码
//先移动temp1指针
temp2=move2;
CarPurchase *move2=new CarPurchase;
temp2->next=move2;
}
//这里注意链表规定 最后节点的next一定要指向NULL
temp2=move2;
temp2->next=NULL;
//个人习惯
move2=head2;
}
void CarPurchase::CarPurchaseDel(CarPurchase *head2,CarPurchase *move2,CarPurchase *temp2)
{
cout<<"请输入要删除的车辆的采购订单号:"<<endl;
long Number=0;
cin>>Number;
if(head2->Purchase_Number==Number)
{
head2=head2->next;
free(head2);
cout<<"成功删除该车辆采购的所有相关信息!"<<endl;
}
else
{
while(move2->next!=NULL)
{
if(move2->Purchase_Number==Number)
{
temp2->next=move2->next;
free(move2);
cout<<"成功删除该车辆采购的所有相关信息!"<<endl;
break;
}
temp2=move2;
move2=move2->next;
}
}
move2=head2;
}
void CarPurchase::CarPurchaseChange(CarPurchase *head2,CarPurchase *move2,CarPurchase *temp2)
{
cout<<"请输入要修改的厂商编号:"<<endl;
long Number=0;
cin>>Number;
while(move2->next!=NULL)
{
if(move2->Purchase_Number==Number)
{
//给节点赋值
cout<<"请输入汽车的采购订单号:"<<endl;;
cin>>move2->Purchase_Number;
//给节点赋值
cout<<"请输入汽车的采购日期:"<<endl;;
cin>>move2->Purchase_Date;
//给节点赋值
cout<<"请输入汽车的厂商编号:"<<endl;;
cin>>move2->Firm_Num;
//给节点赋值
cout<<"请输入汽车的厂商名称:"<<endl;;
cin>>move2->Firm_Name;
//给节点赋值
cout<<"请输入汽车的联系人:"<<endl;;
cin>>move2->Link_Man;
//给节点赋值
cout<<"请输入汽车的联系电话:"<<endl;;
cin>>move2->Link_Num;
//给节点赋值
cout<<"请输入汽车的邮政编码:"<<endl;;
cin>>move2->Zip_Code;
//给节点赋值
cout<<"请输入汽车的通信地址:"<<endl;;
cin>>move2->Mail_Address;
//给节点赋值
cout<<"请输入汽车的车型代码:"<<endl;;
cin>>move2->Car_Code;
//给节点赋值
cout<<"请输入汽车的车辆类型:"<<endl;;
cin>>move2->Car_Type;
//给节点赋值
cout<<"请输入汽车的厂牌型号:"<<endl;;
cin>>move2->Brand_Type;
//给节点赋值
cout<<"请输入汽车的产地:"<<endl;;
cin>>move2->Produce_Area;
//给节点赋值
cout<<"请输入汽车的采购单价:"<<endl;;
cin>>move2->Purchase_price;
//给节点赋值
cout<<"请输入汽车的业务员:"<<endl;;
cin>>move2->Sale_Man;
//给节点赋值
cout<<"请输入汽车的制单员:"<<endl;;
cin>>move2->Produce_Man;
}
move2=move2->next;
}
move2=head2;
}
void CarPurchase::CarPurchaseFind(CarPurchase *head2,CarPurchase *move2,CarPurchase *temp2)
{
cout<<"请输入要查找的车辆的采购订单号:"<<endl;
long Number=0;
cin>>Number;
while(move2->next!=NULL)
{
if(move2->Purchase_Number==Number)
{
cout<<"成功查找到车辆的采购信息!"<<endl;
}
move2=move2->next;
}
move2=head2;
}
void CarPurchase::CarPurchaseInsert(CarPurchase *head2,CarPurchase *move2,CarPurchase *temp2)
{
cout<<"请输入要在哪个车辆的采购订单号后面插入:"<<endl;
long Number=0;
cin>>Number;
while(move2->next!=NULL)
{
if(move2->Purchase_Number==Number)
{
CarPurchase *temp2 = new CarPurchase;
//给节点赋值
cout<<"请输入汽车的采购订单号:"<<endl;;
cin>>move2->Purchase_Number;
//给节点赋值
cout<<"请输入汽车的采购日期:"<<endl;;
cin>>move2->Purchase_Date;
//给节点赋值
cout<<"请输入汽车的厂商编号:"<<endl;;
cin>>move2->Firm_Num;
//给节点赋值
cout<<"请输入汽车的厂商名称:"<<endl;;
cin>>move2->Firm_Name;
//给节点赋值
cout<<"请输入汽车的联系人:"<<endl;;
cin>>move2->Link_Man;
//给节点赋值
cout<<"请输入汽车的联系电话:"<<endl;;
cin>>move2->Link_Num;
//给节点赋值
cout<<"请输入汽车的邮政编码:"<<endl;;
cin>>move2->Zip_Code;
//给节点赋值
cout<<"请输入汽车的通信地址:"<<endl;;
cin>>move2->Mail_Address;
//给节点赋值
cout<<"请输入汽车的车型代码:"<<endl;;
cin>>move2->Car_Code;
//给节点赋值
cout<<"请输入汽车的车辆类型:"<<endl;;
cin>>move2->Car_Type;
//给节点赋值
cout<<"请输入汽车的厂牌型号:"<<endl;;
cin>>move2->Brand_Type;
//给节点赋值
cout<<"请输入汽车的产地:"<<endl;;
cin>>move2->Produce_Area;
//给节点赋值
cout<<"请输入汽车的采购单价:"<<endl;;
cin>>move2->Purchase_price;
//给节点赋值
cout<<"请输入汽车的业务员:"<<endl;;
cin>>move2->Sale_Man;
//给节点赋值
cout<<"请输入汽车的制单员:"<<endl;;
cin>>move2->Produce_Man;
//----
temp2->next=move2->next;
move2->next=temp2;
}
move2=move2->next;
}
temp2=move2;
temp2->next=NULL;
move2=head2;
}
class CarPurchaseInfor
{
public:
void CarPurchaseInforMain();
} CarPurchaseInfor1;
void CarPurchaseInfor::CarPurchaseInforMain()
{
cout<<"\t┠═══════════════════════════┨"<<endl;
cout<<"\t┃ ★1 车辆采购信息的添加 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★2 车辆采购信息的删除 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★3 车辆采购信息的修改 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★4 车辆采购信息的查找 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★5 车辆采购信息的插入 ┃"<<endl;
cout<<"\t┗═══════════════════════════┛"<<endl;
}
//定义一个车辆的销售类,以便操作员对车辆销售
class CarSell
{
public:
//1数据域
long Sell_Num;//销售单号
long Client_Num;//客户编号
string Client_Name;//客户名称
string Car_Code;//车型代码
string Car_Type;//车辆类型
string Produce_Type;//厂牌型号
string Produce_Area;//产地
//2指针域
CarSell *next;
void CarSellAdd(CarSell *head3,CarSell *move3,CarSell *temp3);
void CarSellDel(CarSell *head3,CarSell *move3,CarSell *temp3);
void CarSellChange(CarSell *head3,CarSell *move3,CarSell *temp3);
void CarSellFind(CarSell *head3,CarSell *move3,CarSell *temp3);
void CarSellInsert(CarSell *head3,CarSell *move3,CarSell *temp3);
} CarSell1;
CarSell *head=new CarSell;
void CarSell::CarSellAdd(CarSell *head3,CarSell *move3,CarSell *temp3)
{
cout<<"请输入汽车的数量:"<<endl;
int n =0;
cin>>n;
for(int i=0; i<n; i++)
{
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的销售单号:"<<endl;;
cin>>move3->Sell_Num;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的客户编号:"<<endl;;
cin>>move3->Client_Num;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的客户名称:"<<endl;;
cin>>move3->Client_Name;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的车型代码:"<<endl;;
cin>>move3->Car_Code;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的车辆类型:"<<endl;;
cin>>move3->Car_Type;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的厂牌型号:"<<endl;;
cin>>move3->Produce_Type;
//给节点赋值
cout<<"请输入第"<<i+1<<"辆汽车的产地:"<<endl;;
cin>>move3->Produce_Area;
//--------
//这里就是链表连接的关键代码
//先移动temp1指针
temp3=move3;
CarSell *move3=new CarSell;
temp3->next=move3;
}
//这里注意链表规定 最后节点的next一定要指向NULL
temp3=move3;
temp3->next=NULL;
//个人习惯
move3=head3;
}
void CarSell::CarSellDel(CarSell *head3,CarSell *move3,CarSell *temp3)
{
cout<<"请输入要删除的车辆的销售单号:"<<endl;
long Number=0;
cin>>Number;
if(head3->Sell_Num==Number)
{
head3=head3->next;
free(head3);
cout<<"成功删除该车辆销售的所有相关信息!"<<endl;
}
else
{
while(move3->next!=NULL)
{
if(move3->Sell_Num==Number)
{
temp3->next=move3->next;
free(move3);
cout<<"成功删除该车辆销售的所有相关信息!"<<endl;
break;
}
temp3=move3;
move3=move3->next;
}
}
move3=head3;
}
void CarSell::CarSellChange(CarSell *head3,CarSell *move3,CarSell *temp3)
{
cout<<"请输入要修改的销售单号:"<<endl;
long Number=0;
cin>>Number;
while(move3->next!=NULL)
{
if(move3->Sell_Num==Number)
{
//给节点赋值
cout<<"请输入汽车的销售单号:"<<endl;;
cin>>move3->Sell_Num;
//给节点赋值
cout<<"请输入汽车的客户编号:"<<endl;;
cin>>move3->Client_Num;
//给节点赋值
cout<<"请输入汽车的客户名称:"<<endl;;
cin>>move3->Client_Name;
//给节点赋值
cout<<"请输入汽车的车型代码:"<<endl;;
cin>>move3->Car_Code;
//给节点赋值
cout<<"请输入汽车的车辆类型:"<<endl;;
cin>>move3->Car_Type;
//给节点赋值
cout<<"请输入汽车的厂牌型号:"<<endl;;
cin>>move3->Produce_Type;
//给节点赋值
cout<<"请输入汽车的产地:"<<endl;;
cin>>move3->Produce_Area;
//--------
}
move3=move3->next;
}
move3=head3;
}
void CarSell::CarSellFind(CarSell *head3,CarSell *move3,CarSell *temp3)
{
cout<<"请输入要查找的车辆的销售单号:"<<endl;
long Number=0;
cin>>Number;
while(move3->next!=NULL)
{
if(move3->Sell_Num==Number)
{
cout<<"成功查找到车辆的销售信息!"<<endl;
}
move3=move3->next;
}
move3=head3;
}
void CarSell::CarSellInsert(CarSell *head3,CarSell *move3,CarSell *temp3)
{
cout<<"请输入要在哪个车辆的销售单号后面插入:"<<endl;
long Number=0;
cin>>Number;
while(move3->next!=NULL)
{
if(move3->Sell_Num==Number)
{
CarSell *temp3 = new CarSell;
//给节点赋值
cout<<"请输入汽车的销售单号:"<<endl;;
cin>>move3->Sell_Num;
//给节点赋值
cout<<"请输入汽车的客户编号:"<<endl;;
cin>>move3->Client_Num;
//给节点赋值
cout<<"请输入汽车的客户名称:"<<endl;;
cin>>move3->Client_Name;
//给节点赋值
cout<<"请输入汽车的车型代码:"<<endl;;
cin>>move3->Car_Code;
//给节点赋值
cout<<"请输入汽车的车辆类型:"<<endl;;
cin>>move3->Car_Type;
//给节点赋值
cout<<"请输入汽车的厂牌型号:"<<endl;;
cin>>move3->Produce_Type;
//给节点赋值
cout<<"请输入汽车的产地:"<<endl;;
cin>>move3->Produce_Area;
//--------
temp3->next=move3->next;
move3->next=temp3;
}
move3=move3->next;
}
temp3=move3;
temp3->next=NULL;
move3=head3;
}
class CarSellInfor
{
public:
void CarSellInforMain();
} CarSellInfor1;
void CarSellInfor::CarSellInforMain()
{
cout<<"\t┠═══════════════════════════┨"<<endl;
cout<<"\t┃ ★1 车辆销售信息的添加 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★2 车辆销售信息的删除 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★3 车辆销售信息的修改 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★4 车辆销售信息的查找 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★5 车辆销售信息的插入 ┃"<<endl;
cout<<"\t┗═══════════════════════════┛"<<endl;
}
class CarStore
{
public:
//1数据域
long InStore_Num;//入库单号
long Firm_Num;//厂商编号
string Firm_Name;//厂商名称
string Car_Code;//车型代码
string Car_Type;//车辆类型
string Brand_Type;//厂牌型号
string Produce_Area;//产地
//2指针域
CarStore *next;
void Infor();
void Qsort(int l,int r);
int paixu(int l,int r);
void BarInserch();
void LatterDo();
} CarStore1;
int InStore_N[1000];
int CarStore::paixu(int l,int r)
{
int i=l;
int j=r;
int x=InStore_N[l];
while(i<j)// 结束递归
{
while(i<j && InStore_N[j]>=x) j--;// 从右向左找第一个小于x的数
InStore_N[i]=InStore_N[j];
while(i<j && InStore_N[i]<=x) i++;// 从左向右找第一个大于x的数
InStore_N[j]=InStore_N[i];
}
InStore_N[i]=x;
return i;
}
void CarStore::Qsort(int l,int r)
{
if(l>=r) return;
int x=paixu(l,r);
Qsort(l,x-1);
Qsort(x+1,r);
}
void CarStore::Infor()
{
cout<<"请输入入库单号的数量:"<<endl;
int n;
cin>>n;
for(int i=0; i<n; i++)
{
cout<<"请分别依次输入入库单号:"<<endl;
cin>>InStore_N[i];
}
Qsort(0,n-1);
for(int i=0; i<n; i++)
{
if(i==0)
cout<<InStore_N[i];
else
cout<<" "<<InStore_N[i];
}
cout<<"车辆的入库单号从小到大排序成功!"<<endl;
}
void CarStore::BarInserch()
{
int n;
int flag;//设置一个标记变量
int key,mid,low,high;
cout<<"请输入入库单号的数量:"<<endl;
cin>>n;
flag=-1;//特殊标记
low=1;
high=n;
for(int i=1; i<=n; i++)
{
cout<<"请依次输入n个递增的入库单号的序列:"<<endl;
cin>>InStore_N[i];
}
cout<<"请输入你要查询的入库单号:"<<endl;
cin>>key;
while(low<=high)
{
mid=(low+high)/2;
if(key==InStore_N[mid])
{
flag=mid;
break;
}
else if(key<InStore_N[mid])
{
high=mid-1;
}
else if(key>InStore_N[mid])
{
low=mid+1;
}
}
if(flag!=-1)
{
cout<<"存在要查找的入库单号的信息,查找成功!"<<endl;
}
else
{
cout<<"不存在要查找的入库单号的信息,查找失败!"<<endl;
}
}
void CarStore::LatterDo()
{
stack<int>q;
int T;
string str;
cout<<"请输入入库单的数量:"<<endl;
cin>>T;
for(int i=0; i<T; i++)
{
stack<int> q;
for(int i=0; i<T; i++)
{
cout<<"输入一个字符串来表示你要进行的操作:"<<endl;
cout<<"1:push代表你要在入库单后面再添加。"<<endl;
cout<<"2:pop代表你要删除最后面的入库单号。"<<endl;
cout<<"3:top代表你要找出最后面的入库单号。"<<endl;
cout<<"请输入3个关键词中的其中一个:"<<endl;
cin>>str; //操作判断
if(str=="push")
{
int n;
cout<<"请输入你要添加的入库单号:"<<endl;
cin>>n;
q.push(n);//进栈
continue;
}
else if(str=="top")
{
if(q.empty())
{
cout<<"empty"<<endl; //清空判断
cout<<"这是一个空的入库单号!"<<endl;
}
else
{
cout<<q.top()<<endl;
cout<<"成功查找到最后一个入库单号!"<<endl;
}
continue;
}
else if(str=="pop")
{
if(q.empty())
{
cout<<"error"<<endl;
cout<<"这是一个空的入库单号!"<<endl;
}
else
{
q.pop(); //删除第一个元素
cout<<"成功删除最后一个入库单号!"<<endl;
}
continue;
}
}
cout<<endl;//注意要求,多空一行
}
}
class CarStoreInfor
{
public:
void CarStoreInforMain();
} CarStoreInfor1;
void CarStoreInfor::CarStoreInforMain()
{
cout<<"\t┠═══════════════════════════┨"<<endl;
cout<<"\t┃ ★1 按照入库单号从小到大的排序 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★2 查找入库单号 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┃ ★3 在入库单号后面添加一个新入库单号 ┃"<<endl;
cout<<"\t┃ 删除最后面的入库单号 ┃"<<endl;
cout<<"\t┃ 找出最后面的入库单号 ┃"<<endl;
cout<<"\t┃ ┃"<<endl;
cout<<"\t┗═══════════════════════════┛"<<endl;
}
//主函数
int main()
{
int choose=0;
MainMenu1.ShowMain();
cout<<"请选择你的操作:"<<endl;
system("color 0c");//调用系统的颜色函数
while(1)
{
cin>>choose;
if(choose)
{
if(choose==1)
{
Operator1.Cin();
Operator1.Cout();
Sleep(1000);
system("cls");
OperatorMain1.OperatorShow();
cout<<"请选择管理的对象:"<<endl;
int choose0;
cin>>choose0;
if(choose0==1)
{
system("cls");
UserInfor1.ShowInfor();
User *head1,*move1,*temp1;
head1=move1=(User *)malloc(sizeof(User));
int choose1=0;
cout<<"请选择对用户信息的操作"<<endl;
cin>>choose1;
if(choose1==1)
{
User1.UserAdd(head1,move1,temp1);
Sleep(1000);
}
else if(choose1==2)
{
User1.UserDel(head1,move1,temp1);
Sleep(1000);
}
else if(choose1==3)
{
User1.UserChange(head1,move1,temp1);
Sleep(1000);
}
else if(choose1==4)
{
User1.UserFind(head1,move1,temp1);
Sleep(1000);
}
else if(choose1==5)
{
User1.UserInsert(head1,move1,temp1);
Sleep(1000);
}
}
if(choose0==2)
{
system("cls");
CarPurchaseInfor1.CarPurchaseInforMain();
CarPurchase *head2,*move2,*temp2;
head2=move2=(CarPurchase *)malloc(sizeof(CarPurchase));
int choose2=0;
cout<<"请选择对车辆采购信息的操作"<<endl;
cin>>choose2;
if(choose2==1)
{
CarPurchase1.CarPurchaseAdd(head2,move2,temp2);
Sleep(1000);
}
else if(choose2==2)
{
CarPurchase1.CarPurchaseDel(head2,move2,temp2);
Sleep(1000);
}
else if(choose2==3)
{
CarPurchase1.CarPurchaseChange(head2,move2,temp2);
Sleep(1000);
}
else if(choose2==4)
{
CarPurchase1.CarPurchaseFind(head2,move2,temp2);
Sleep(1000);
}
else if(choose2==5)
{
CarPurchase1.CarPurchaseInsert(head2,move2,temp2);
Sleep(1000);
}
}
if(choose0==3)
{
system("cls");
CarSellInfor1.CarSellInforMain();
CarSell *head3,*move3,*temp3;
head3=move3=(CarSell *)malloc(sizeof(CarSell));
int choose3=0;
cout<<"请选择对车辆销售信息的操作"<<endl;
cin>>choose3;
if(choose3==1)
{
CarSell1.CarSellAdd(head3,move3,temp3);
Sleep(1000);
}
else if(choose3==2)
{
CarSell1.CarSellDel(head3,move3,temp3);
Sleep(1000);
}
else if(choose3==3)
{
CarSell1.CarSellChange(head3,move3,temp3);
Sleep(1000);
}
else if(choose3==4)
{
CarSell1.CarSellFind(head3,move3,temp3);
Sleep(1000);
}
else if(choose3==5)
{
CarSell1.CarSellInsert(head3,move3,temp3);
Sleep(1000);
}
}
if(choose0==4)
{
system("cls");
CarStoreInfor1.CarStoreInforMain();
int choose4=0;
cout<<"请选择你对入库信息的操作:"<<endl;
cin>>choose4;
if(choose4==1)
{
CarStore1.Infor();
Sleep(1000);
}
if(choose4==2)
{
CarStore1.BarInserch();
Sleep(1000);
}
if(choose4==3)
{
CarStore1.LatterDo();
Sleep(1000);
}
}
if(choose0==0)
{
system("cls");
break;
}
}
}
}
return 0;
}