C++趣味实践项目(超市管理系统、校园导航系统)

1️⃣🦉超市管理系统(字符界面)🧸

|*🐧程序1:超市管理系统🧸*|

#include<iostream>
using namespace std;
#include<iomanip>	// setw()函数 
#include<cstring>	// strcpy()函数 
#include<windows.h>	// C头文件引入 在交互模式下 背景及字体 颜色 头文件 
#include<ctime>		// 引入 时间模块 
#include<conio.h>	// 引入 操作系统 头文件 getch() 
void Setcolor_0211adby(int uBack_0211adby, int uFore_0211adby)   // uBack 背景色、 uFore 前景色 
{
	HANDLE handle_0211adby = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleTextAttribute(handle_0211adby, uFore_0211adby + uBack_0211adby*0x10);
}

class Goods_0211adby      // 每一个商品信息类: 条形码号    名称	  价格  剩余数量 
{
	long long GoodsId_0211adby;		// 条形码号 
	char *GoodsName_0211adby;		// 名字 
	float GoodsPrice_0211adby;		// 单价 
	int Amount_0211adby;			// 剩余数量 
public:
	long long GetId_0211adby(void){		// 通过公有函数接口 获得 该商品的条形码号 
		return GoodsId_0211adby;
	}	
	char* GetName_0211adby(void){		// 通过公有函数接口 获得 该商品的名称 
		return GoodsName_0211adby;
	}
	float GetPrice_0211adby(void){		// 通过公有函数接口 获得 该商品的单价 
		return GoodsPrice_0211adby;
	}
	int GetAmount_0211adby(void){
		return Amount_0211adby;
	}
	void ModifyAmount_0211adby(int number_0211adby){
		Amount_0211adby = number_0211adby;
	}
	void ShowExample_0211adby(void)
	{
		Setcolor_0211adby(0, 12);
		cout << setw(32) << "商品条形码号" << setw(30) << "商品名称" << setw(20) << "商品单价"  << setw(20) << "库存量" << endl; 
		Setcolor_0211adby(0, 7);
	 } 
	void Id_Show(long long GoodsId_0211adby){	//   通过商品条形码号  显示 该物品的所有信息 
		Setcolor_0211adby(0, 9);
		cout << setw(32) << this->GoodsId_0211adby << setw(30)  << GoodsName_0211adby << setw(20) << fixed  << setprecision(2) << GoodsPrice_0211adby << endl;
		Setcolor_0211adby(0, 7);	
	}
	void Show_0211adby(void){					// 通过公有函数接口 显示 超市指定货物信息 
		Setcolor_0211adby(0, 9);
		cout << setw(32) << this->GoodsId_0211adby << setw(30)  << GoodsName_0211adby << setw(20) << fixed  << setprecision(2) << GoodsPrice_0211adby << endl;
		Setcolor_0211adby(0, 7);
	}
	Goods_0211adby(long long GoodsId_0211adby = 0, char *GoodsName_0211adby = NULL, float GoodsPrice_0211adby = 0.0){	// 构造函数-->1, 
		this->GoodsId_0211adby = GoodsId_0211adby;
		if(GoodsName_0211adby){
			 this->GoodsName_0211adby = new char[strlen(GoodsName_0211adby)+1];
			 strcpy(this->GoodsName_0211adby, GoodsName_0211adby);
		}else{
			this->GoodsName_0211adby = NULL;
		}
		this->GoodsPrice_0211adby = GoodsPrice_0211adby;
	}
	Goods_0211adby(const Goods_0211adby& OneGoods_0211adby)			//  拷贝构造函数 
	{
		GoodsId_0211adby = OneGoods_0211adby.GoodsId_0211adby;
		if(OneGoods_0211adby.GoodsName_0211adby){
			 this->GoodsName_0211adby = new char[strlen(OneGoods_0211adby.GoodsName_0211adby)+1];
			 strcpy(this->GoodsName_0211adby, OneGoods_0211adby.GoodsName_0211adby);
		}else{
			this->GoodsName_0211adby = NULL;
		}
		this->GoodsPrice_0211adby = OneGoods_0211adby.GoodsPrice_0211adby;
	}
	~Goods_0211adby(void)										// 析构函数 
	{
		if(GoodsName_0211adby)
			delete []GoodsName_0211adby;
	}
	Goods_0211adby &operator=(const Goods_0211adby& OneGoods_0211adby)				// 赋值运算符重载函数 
	{
		GoodsId_0211adby = OneGoods_0211adby.GoodsId_0211adby;
		if(OneGoods_0211adby.GoodsName_0211adby){
			 this->GoodsName_0211adby = new char[strlen(OneGoods_0211adby.GoodsName_0211adby)+1];
			 strcpy(this->GoodsName_0211adby, OneGoods_0211adby.GoodsName_0211adby);
		}else{
			this->GoodsName_0211adby = NULL;
		}
		this->GoodsPrice_0211adby = OneGoods_0211adby.GoodsPrice_0211adby;
		return *this; 
	}
	void ModifyInfo_0211adby(long long GoodsId_0211adby = 0, char *GoodsName_0211adby = NULL, float GoodsPrice_0211adby = 0.0)  // 重载函数--->2 
	{
		this->GoodsId_0211adby = GoodsId_0211adby;
		if(GoodsName_0211adby){
			 this->GoodsName_0211adby = new char[strlen(GoodsName_0211adby)+1];
			 strcpy(this->GoodsName_0211adby, GoodsName_0211adby);
		}else{
			this->GoodsName_0211adby = NULL;
		}
		this->GoodsPrice_0211adby = GoodsPrice_0211adby;
	}
};

struct SaveGoods_0211adby           		// 链表结构    每一个 结点包括     1.商品信息   2.和指向下一个结点的指针 
{
	Goods_0211adby articleIfno_0211adby;  	// 每一个商品的信息 的! !!!头指针  Error] field 'articleIfno_0211adby' has incomplete type
	SaveGoods_0211adby *next;				// 指向下一个货物的信息 的指针 
};
class Cart_0211adby: public Goods_0211adby	// 定义一个 购买每一个货物信息的类(派生类) 
{
	int number_0211adby;					// 该商品购买数量 
	
public:
	int GetNumber_0162(void){				// 获取该商品数量 
		return number_0211adby;
	}
	void InitalNumber_0211adby(void)	{	// 初始化购买该商品数量为 0 
		number_0211adby = 0;
	}
	void ModifyNumber_0162dme(int number_0211adby ){	// 通过传入数量来修改 该购买商品数量 
		this->number_0211adby += number_0211adby;
	}
	void AccountExample_0211adby(void){					// 显示购买货物的信息 
		Setcolor_0211adby(0, 12);
		cout << setw(32) << "商品条形码号" << setw(30) << "商品名称" << setw(20) << "商品单价" << setw(20) << "数量" << endl;
		Setcolor_0211adby(0, 7);
	}
	void Account_0211adby(void){						// 显示每一种购买的货物的具体信息 
		Setcolor_0211adby(0, 9);
		cout << setw(32) << GetId_0211adby() << setw(30) << this->GetName_0211adby() << setw(20) << fixed << setprecision(2) << GetPrice_0211adby()  << setw(20) << this->GetNumber_0162() << endl;
		Setcolor_0211adby(0, 7);
	}
	float OneAccount_0211adby(void){					// 返回 购买每种商品的金额 
		return GetPrice_0211adby() * GetNumber_0162();
	}
};
struct Purchase_0211adby{				// 链表结构    每一个 结点包括     1.购买物品信息   2.和指向下一个结点的指针
	Cart_0211adby article_0211adby;		// 每一个购买商品的信息
	Purchase_0211adby *next;			// 指向下一个购买货物的信息 的指针 
}; 
long long JudgeId_0211adby(char *p); 	// 检查输入条形码号是否正确 
float JudegPrice_0211adby(char *p);		// 检查输入价格是否正确 
int JudgeSelect_0211adby(char *p);		// 检查输入选择功能时是否为自然数 
void ShowTime_0211adby(void);			// 显示当前时间
void WelcomeSupermarket_0211adby(void);	// 封面设置 1
void LeaveSupermarket_0211adby(void);	// 封面设置 2 
void SelectMenu_0211adby(SaveGoods_0211adby **HeadSave_0211adby, Purchase_0211adby **HeadPurchase_0211adby);				// 声明一个 选择菜单 函数 
void PauseClear_0211adby(void);
void Clear_0211adby(void);
void Pause_0211adby(void);
void GoodsBarcodeAsc_0211adby(SaveGoods_0211adby** HeadB_0211adby);
int main(void)			// 主函数 
{	
	SaveGoods_0211adby* HeadSave_0211adby = NULL;			// 定义一个 商品信息的链表 
	Purchase_0211adby* HeadPurchase_0211adby = NULL;      // 定义一个购物车链表 
	SelectMenu_0211adby(&HeadSave_0211adby, &HeadPurchase_0211adby);	// 将链表头的地址 传递给 选择菜单函数 
	return 0;	
}
void ShowMenu_0211adby(void)					// 显示菜单 的服务选项 
{
	Setcolor_0211adby(0, 12);
	cout << "\n\n\n" << setw(114)<<"☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆  ☆     超 市  管 理 系  统     ☆  ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆" << endl << endl;
	Setcolor_0211adby(0, 2);
	cout << setw(86) << "*************        0: 离开超市        *************" << endl<<endl;
	Setcolor_0211adby(0, 11);
	cout << setw(86) << "*************   1: 建立超市商品信息库   *************" << endl<<endl;
	cout << setw(86) << "*************      2: 删除超市商品      *************" << endl<<endl;
	cout << setw(86) << "*************        3: 增添商品        *************" << endl<<endl;
	Setcolor_0211adby(0, 7);
	cout << setw(86) << "*************        4: 查询商品        *************" << endl<<endl;
	cout << setw(86) << "*************      5: 查看所有商品      *************" << endl<<endl;
	cout << setw(86) << "*************        6: 商品排号        *************" << endl<<endl;
	Setcolor_0211adby(0, 9);
	cout << setw(86) << "*************        7: 选购商品        *************" << endl<<endl;
	cout << setw(86) << "*************     8: 显示购物车商品     *************" << endl<<endl;
	cout << setw(86) << "*************        9: 结算商品        *************" << endl<<endl;
	Setcolor_0211adby(0, 2);
	cout << setw(86) << "*************       10: 号码升序        *************" << endl<<endl;
	Setcolor_0211adby(0, 7);
	cout << setw(66) << "请选择: 0 ~ 9" << endl<<endl;
}

void CreatGoodsInfo(SaveGoods_0211adby** HeadSave_0211adby)		// 创建超市商品信息函数 
{
	SaveGoods_0211adby** Head_0211adby = HeadSave_0211adby;
	
	if(*Head_0211adby)	// 确保录入的之前超市没有商品信息 
	{	
		cout << endl << endl;
		Setcolor_0211adby(0, 8);cout << setw(116)<< "┏━┓┏━┓┏━┓▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉┏━┓┏━┓┏━┓" << endl;
		Setcolor_0211adby(0, 4);cout << setw(59) << "哦!铭萌雏欣提醒您|货物信息库已存在|不可建库!哒" << endl;
		Setcolor_0211adby(0, 8);cout << setw(116) << "┏━┓┏━┓┏━┓▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉┏━┓┏━┓┏━┓" << endl;
		PauseClear_0211adby();
		return ;
	}
	SaveGoods_0211adby* traverse_0211adby = NULL;
	SaveGoods_0211adby* p1_0211adby = NULL;
	SaveGoods_0211adby* p2_0211adby = NULL;
	
	char GoodsId_0211adby[20];		
	char GoodsName_0211adby[30];
	char GoodsPrice_0211adby[20];
	int flag_0211adby = 0;
	while(1)
	{	Setcolor_0211adby(0, 10);  // 绿色字体 
		cout << endl << endl;
		cout << "注意依次输入 0 0 0 停止录取商品信息!" << endl;
		cout << setw(50)<< "请输入商品条形码号: ";Setcolor_0211adby(0, 9); cin >> GoodsId_0211adby; cout <<  endl; Setcolor_0211adby(0, 10);
		cout << setw(50)<< "请输入商品名称: ";Setcolor_0211adby(0, 9); cin >> GoodsName_0211adby; cout <<  endl;Setcolor_0211adby(0, 10);
		cout << setw(50)<< "请输入商品价格: ";Setcolor_0211adby(0, 9); cin >> GoodsPrice_0211adby; cout <<  endl;
	
		if(JudgeId_0211adby(GoodsId_0211adby) == -1)	{
			cout << endl << endl;Setcolor_0211adby(0, 3);cout <<setw(27) <<  "┭┮﹏┭┮";
			Setcolor_0211adby(0, 4);	cout<<" 条形码号输入错误";Setcolor_0211adby(0, 9);cout<<" O(∩_∩)O" << endl;
			PauseClear_0211adby();
			continue;
		}else if(JudegPrice_0211adby(GoodsPrice_0211adby) == -1){
			cout << endl << endl;Setcolor_0211adby(0, 3);cout <<setw(27) <<  "┭┮﹏┭┮";
			Setcolor_0211adby(0, 4);	cout<<" 单价输入错误";Setcolor_0211adby(0, 9);cout<<" O(∩_∩)O" << endl;
			PauseClear_0211adby();
			continue;
		}
		if(JudgeId_0211adby(GoodsId_0211adby) == 0){
			Clear_0211adby();
			cout << endl << endl;
			Setcolor_0211adby(0, 8);cout << setw(90)<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
			Setcolor_0211adby(0, 4);cout << setw(55) << "哦!铭萌雏欣提醒您|商品库建立完成!哒" << endl;
			Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
			PauseClear_0211adby();
			break;
		}
		while(traverse_0211adby)
		{	
			if(traverse_0211adby->articleIfno_0211adby.GetId_0211adby() == JudgeId_0211adby(GoodsId_0211adby))
			{	
				cout << endl << endl; Setcolor_0211adby(0, 14);	cout << setw(30)<< "↓↓|→→|";
				Setcolor_0211adby(0, 2);	cout<<" 嘿哈,请看下面信息";Setcolor_0211adby(0, 14);	cout<<" |←←|↓↓" << endl << endl;
				Setcolor_0211adby(0, 9u); cout << setw(81) << "☆ ☆ ☆ ☆ 铭萌雏欣小超市 ☆ ☆ ☆ ☆" << endl << endl;
				traverse_0211adby->articleIfno_0211adby.ShowExample_0211adby();
				traverse_0211adby->articleIfno_0211adby.Id_Show(JudgeId_0211adby(GoodsId_0211adby));
				cout << endl << endl;	Setcolor_0211adby(0, 14);	cout<< setw(20) << "↑↑|→→|";
				Setcolor_0211adby(0, 4); cout<<" 该条形码号已经使用过啦,请输入新的条形码号哦"; Setcolor_0211adby(0, 14);
				cout<<" |←←|↑↑" << endl;
				PauseClear_0211adby();
					flag_0211adby = 1; 
					break;
			}
			traverse_0211adby = traverse_0211adby->next;
		} 
		if(flag_0211adby)
		{	
			flag_0211adby = 0;
			traverse_0211adby = *Head_0211adby;
			continue;
		}
		p1_0211adby = new SaveGoods_0211adby;
		if(*Head_0211adby){
			p2_0211adby->next = p1_0211adby;
			p2_0211adby = p1_0211adby;
		}else{
			*Head_0211adby = p2_0211adby = p1_0211adby;
		}
		p1_0211adby->articleIfno_0211adby.ModifyInfo_0211adby(JudgeId_0211adby(GoodsId_0211adby), GoodsName_0211adby, JudegPrice_0211adby(GoodsPrice_0211adby));
		p2_0211adby->next = NULL;
		traverse_0211adby = *HeadSave_0211adby;

	cout << endl << endl;
	Setcolor_0211adby(0, 12);cout << setw(30) << "成功添加";	Setcolor_0211adby(0, 14);	cout << " ▉▉▉▉▉▉  ";
	Setcolor_0211adby(0, 10);cout  <<GoodsName_0211adby; Setcolor_0211adby(0, 14);cout << "  ▉▉▉▉▉▉";
	Setcolor_0211adby(0, 12);cout << " 到 "; Setcolor_0211adby(0, 9u);cout<<"☆ ☆ ☆ ☆ 铭萌雏欣小超市 ☆ ☆ ☆ ☆"<<endl; 
	PauseClear_0211adby();
	}
	if(p2_0211adby)
		p2_0211adby->next = NULL;
	Setcolor_0211adby(0, 7);
}
int Release_0211adby(SaveGoods_0211adby** HeadSave_0211adby, Purchase_0211adby** HeadB_0211adby)		// 释放超市商品信息库占有内存的空间 
{
	if(*HeadB_0211adby){
		cout << endl << endl;Setcolor_0211adby(0, 5);cout << "o((>ω< ))o";Setcolor_0211adby(0, 4); 
		cout<<" 哎呦,干嘛,账都没结,就想走,乖乖去结账";Setcolor_0211adby(0, 9);cout<<" ε(┬┬﹏┬┬)3" << endl;
		PauseClear_0211adby();
		return 0;
	}
	SaveGoods_0211adby** Head_0211adby = HeadSave_0211adby;
	SaveGoods_0211adby* p_0211adby = NULL;
	while(*Head_0211adby)
	{
		p_0211adby = *Head_0211adby;
		*Head_0211adby = (*Head_0211adby)->next;
		delete p_0211adby;
	}
	return 1;
}
void ShowInfo_0211adby(SaveGoods_0211adby** HeadSave_0211adby)			// 查询超市商品信息函数 
{
	char id_0211adby[20];
	char name_0211adby[30];
	int quit_0211adby = 0;
	int flag_0211adby = 0;
	char select_0211adby[15];
	int noreplay_0211adby = 1;
	SaveGoods_0211adby** Head_0211adby = HeadSave_0211adby;
	SaveGoods_0211adby* p_0211adby = *Head_0211adby;
	
	while(1){
		
		Setcolor_0211adby(0, 1);			// 蓝色字体 
		cout << setw(101)<< "********************************************************************************************"<< endl\
         << "\t   0: 退出查询功能            1:通过条形码查询商品信息            2: 通过商品名称查询其信息" << endl
         << setw(101)<< "********************************************************************************************" << endl;
         
		Setcolor_0211adby(0, 2);		// 绿色字体 
		cout << "请输入你选择的功能>> ";
		cin >> select_0211adby;

		switch(JudgeSelect_0211adby(select_0211adby))
		{
			Setcolor_0211adby(0, 2);		// 绿色字体 
			case 0: quit_0211adby = 1; break;
			case 1:{
				cout << "请输入商品条形码: "; Setcolor_0211adby(0, 9);
				cin >> id_0211adby;
				if(JudgeId_0211adby(id_0211adby) == -1)
				{	cout << endl << endl;Setcolor_0211adby(0, 3);cout <<setw(27) <<  "┭┮﹏┭┮";
					Setcolor_0211adby(0, 4);	cout<<" 条形码号输入错误";Setcolor_0211adby(0, 9);cout<<" O(∩_∩)O" << endl;
					PauseClear_0211adby();
					flag_0211adby = 1;
					break;
				}
				while(p_0211adby){
					if(p_0211adby->articleIfno_0211adby.GetId_0211adby() == JudgeId_0211adby(id_0211adby)){
						Setcolor_0211adby(0, 7);  // 白色字体 
						p_0211adby->articleIfno_0211adby.ShowExample_0211adby();	
						Setcolor_0211adby(0, 1);  // 蓝色字体 
						p_0211adby->articleIfno_0211adby.Show_0211adby();	
						flag_0211adby = 1;
					}
					p_0211adby = p_0211adby->next;
				}	break;
			}
			case 2:{
				cout << "请输入商品名称: ";
				cin >> name_0211adby;
				while(p_0211adby){
					if(strcmp(p_0211adby->articleIfno_0211adby.GetName_0211adby(),name_0211adby) == 0)
					{
						if(noreplay_0211adby){
							Setcolor_0211adby(0, 7);  // 白色字体 
							p_0211adby->articleIfno_0211adby.ShowExample_0211adby(); 
						}
						Setcolor_0211adby(0, 1);  // 蓝色字体 
						p_0211adby->articleIfno_0211adby.Show_0211adby();
						flag_0211adby = 1;
						noreplay_0211adby = 0;
					}
					p_0211adby = p_0211adby->next;
				}	break;
			}
			default: {cout << endl << endl;
				Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				Setcolor_0211adby(0, 4);cout << setw(50) << "哦!输入错误|无法查询!哒" << endl;
				Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				PauseClear_0211adby();
				flag_0211adby = 1;
				break;
			}
		}
		if(quit_0211adby){
			cout << endl << endl;
			Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
			Setcolor_0211adby(0, 5);cout << setw(51) << "哦!成功退出查询功服务!哒" << endl;
			Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
			PauseClear_0211adby();
			break;	
		}
			
		if(!flag_0211adby){
			cout << endl << endl;
			Setcolor_0211adby(0, 8);cout << setw(90)<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
			Setcolor_0211adby(0, 4);cout << setw(50) << "哦!铭萌雏欣|没该商品!哒" << endl;
			Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
			PauseClear_0211adby();
		}	
		p_0211adby = *Head_0211adby;
		flag_0211adby = 0;
		noreplay_0211adby = 1;
	}
}
void ShowAll_0211adby(SaveGoods_0211adby** HeadSave_0211adby)		// 显示超市中所有商品信息的函数 
{
	SaveGoods_0211adby** Head_0211adby = HeadSave_0211adby;
	SaveGoods_0211adby* p_0211adby = *Head_0211adby;
	if(!*Head_0211adby)	// 确保超市没有货物
	{
		cout << endl << endl;
		Setcolor_0211adby(0, 8);cout << setw(90)<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
		Setcolor_0211adby(0, 4);cout << setw(50) << "哦!铭萌雏欣|没该商品!哒" << endl;
		Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
		PauseClear_0211adby();
		return ;
	}
	Setcolor_0211adby(0, 7);		// 白色字体 
	p_0211adby->articleIfno_0211adby.ShowExample_0211adby();
	Setcolor_0211adby(0, 1);		// 蓝色字体 
	while(p_0211adby){
		p_0211adby->articleIfno_0211adby.Show_0211adby();
		p_0211adby = p_0211adby->next;
	}
	PauseClear_0211adby();
}
void DeleteItem_0211adby(Purchase_0211adby** HeadCart_0211adby)		// 删除购物车中某件商品数量 
{
	
	Purchase_0211adby** Head_0211adby = HeadCart_0211adby;
	Purchase_0211adby* p_0211adby = *HeadCart_0211adby;
	char id_0211adby[20];
	int flag_0211adby = 1;
	
	if(!p_0211adby){
		cout << endl << endl;
		Setcolor_0211adby(0, 8);cout << setw(90)<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
		Setcolor_0211adby(0, 4);cout << setw(50) << "哦!铭萌雏欣提醒您|当前购物车为空!哒" << endl;
		Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
		PauseClear_0211adby();
		return ;
	}
	Setcolor_0211adby(0, 2);		// 绿色字体 
	cout  << setw(50) << "请输入要去掉商品的条形码号: "; Setcolor_0211adby(0, 9);
	cin >> id_0211adby;
	if(JudgeId_0211adby(id_0211adby) == -1)
	{	cout << endl << endl;Setcolor_0211adby(0, 3);cout <<setw(27) <<  "┭┮﹏┭┮";
		Setcolor_0211adby(0, 4);	cout<<" 条形码号输入错误";Setcolor_0211adby(0, 9);cout<<" O(∩_∩)O" << endl;
		PauseClear_0211adby();
		return ;
	}
	while(p_0211adby)
	{
		if(p_0211adby->article_0211adby.GetId_0211adby() == JudgeId_0211adby(id_0211adby))
		{
			flag_0211adby = 0;
			if(p_0211adby->article_0211adby.GetNumber_0162() > 0){
				p_0211adby->article_0211adby.ModifyNumber_0162dme(-1);
				Setcolor_0211adby(0, 8);cout << setw(92)<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				Setcolor_0211adby(0, 4);cout << setw(55) << "哦!铭萌雏欣提醒您|减少了一件该商品!哈" << endl;
				Setcolor_0211adby(0, 8);cout << setw(92) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				PauseClear_0211adby();
			}
			else{
				cout << endl << endl;
				Setcolor_0211adby(0, 8);cout << setw(90)<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				Setcolor_0211adby(0, 4);cout << setw(55) << "哦!铭萌雏欣提醒您|购物车没该商品!呢" << endl;
				Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				PauseClear_0211adby();
			}
		}
		p_0211adby = p_0211adby->next;
	}
	if(flag_0211adby){
		cout << endl << endl;
		Setcolor_0211adby(0, 8);cout << setw(90)<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
		Setcolor_0211adby(0, 4);cout << setw(55) << "哦!铭萌雏欣提醒您|购物车没该商品!呢" << endl;
		Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
		PauseClear_0211adby();
	}
}
void AddItem_0211adby(SaveGoods_0211adby **HeadSave_0211adby, Purchase_0211adby** HeadPurchase_0211adby)
{
	Purchase_0211adby** HeadCart_0211adby = HeadPurchase_0211adby;
	Purchase_0211adby* PX_0211adby = NULL;
	Purchase_0211adby* PX2_0211adby = NULL;
	Purchase_0211adby* Cycle_0211adby = *HeadCart_0211adby;
	
	SaveGoods_0211adby* p_0211adby = *HeadSave_0211adby;
	int flag2_0211adby = 1;
//	int stop_0211adby = 0;

	char id_0211adby[20];
	int have_0211adby = 1;
	while(Cycle_0211adby){
		PX2_0211adby = Cycle_0211adby;
		Cycle_0211adby = Cycle_0211adby->next;
	}
	Cycle_0211adby = *HeadCart_0211adby;
	Setcolor_0211adby(0, 2);			// 绿色字体 
	cout << setw(50) << "请输入所购买商品的条形码号: ";
	cin >> id_0211adby;
	if(JudgeId_0211adby(id_0211adby) == -1)
	{	cout << endl << endl;Setcolor_0211adby(0, 3);cout <<setw(27) <<  "┭┮﹏┭┮";
		Setcolor_0211adby(0, 4);	cout<<" 条形码号输入错误";Setcolor_0211adby(0, 9);cout<<" O(∩_∩)O" << endl;
		PauseClear_0211adby(); 
		return ;
	}
	
	while(p_0211adby)
	{
		have_0211adby = 1; 
		if(p_0211adby->articleIfno_0211adby.GetId_0211adby() == JudgeId_0211adby(id_0211adby))
		{
			flag2_0211adby = 0;

			while(Cycle_0211adby)
			{
				if(Cycle_0211adby->article_0211adby.GetId_0211adby() == JudgeId_0211adby(id_0211adby))
				{
					have_0211adby = 0;
					break;
				}	
				Cycle_0211adby = Cycle_0211adby->next;
			}	
			if(have_0211adby)
			{
				PX_0211adby = new Purchase_0211adby;
				PX_0211adby->article_0211adby.InitalNumber_0211adby();
				PX_0211adby->article_0211adby.ModifyNumber_0162dme(1);
				
				if(*HeadCart_0211adby)
				{
					PX2_0211adby->next = PX_0211adby;
					PX2_0211adby = PX_0211adby;
				}else{
					*HeadCart_0211adby = PX2_0211adby = PX_0211adby;
				}
				PX_0211adby->article_0211adby.ModifyInfo_0211adby(p_0211adby->articleIfno_0211adby.GetId_0211adby(), p_0211adby->articleIfno_0211adby.GetName_0211adby(), p_0211adby->articleIfno_0211adby.GetPrice_0211adby());
				cout << endl << endl; 
				Setcolor_0211adby(0, 8);cout << setw(90)<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				Setcolor_0211adby(0, 4);cout << setw(55) << "哦!铭萌雏欣提醒您|商品添加购物车!哒" << endl;
				Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				PauseClear_0211adby();
			}
			else{
				Cycle_0211adby->article_0211adby.ModifyNumber_0162dme(1);		cout << endl << endl; 
				Setcolor_0211adby(0, 8);cout << setw(90)<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				Setcolor_0211adby(0, 4);cout << setw(55) << "哦!铭萌雏欣提醒您|商品添加购物车!哒" << endl;
				Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				PauseClear_0211adby();
			}
				
			
			PX2_0211adby->next = NULL;
			Cycle_0211adby = *HeadCart_0211adby;
		}	
		p_0211adby = p_0211adby->next;
	}
	if(flag2_0211adby){
		cout << endl << endl;Setcolor_0211adby(0, 3);cout <<setw(27) <<  "┭┮﹏┭┮";
		Setcolor_0211adby(0, 4);	cout<<" 条形码号输入错误";Setcolor_0211adby(0, 9);cout<<" O(∩_∩)O" << endl;
	}
}
void Trolley_0211adby(SaveGoods_0211adby **HeadSave_0211adby, Purchase_0211adby** HeadPurchase_0211adby)	// 选购函数 
{
	int flag_0211adby = 0;
	Purchase_0211adby** HeadCart_0211adby = HeadPurchase_0211adby;

	SaveGoods_0211adby** Head_0211adby = HeadSave_0211adby;

	char select_0211adby[15];
	
	while(1)
	{	
		Setcolor_0211adby(0, 1);		// 蓝色字体 
		cout<< setw(101)<< "********************************************************************************************"<< endl\
         	<< "\t\t\t 0: 退出选购服务            1: 购买商品            2:删除商品" << endl
         	<< setw(101)<< "********************************************************************************************" << endl;
		
		Setcolor_0211adby(0, 2);		// 绿色字体 
		cout << "请输入你所选择的功能>>  ";
		cin >> select_0211adby;
		
		switch(JudgeSelect_0211adby(select_0211adby))
		{
			case 0: flag_0211adby = 1; break;
			case 1: AddItem_0211adby(HeadSave_0211adby, HeadPurchase_0211adby); break;
			case 2: DeleteItem_0211adby(HeadPurchase_0211adby); break; // cout << "该功能尚未开发!!!!" << endl ;
			default :{
				cout << endl << endl;
				Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				Setcolor_0211adby(0, 4);cout << setw(50) << "哦!输入错误|无法查询!哒" << endl;
				Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				PauseClear_0211adby();
			}
		}
		if(flag_0211adby)
		{
			Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
			Setcolor_0211adby(0, 5);cout << setw(50) << "哦!成功退出选购服务!哒" << endl;
			Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
			PauseClear_0211adby();
			break;
		}
	}
}
void Check_0211adby(Purchase_0211adby** HaedPurchase_0211adby)   // 进行结账函数 
{
	Purchase_0211adby** HeadCart_0211adby = HaedPurchase_0211adby; 
	Purchase_0211adby* PX_0211adby = *HeadCart_0211adby;
	float money_0211adby = 0;
	if(!PX_0211adby)
	{	cout << endl << endl;
		Setcolor_0211adby(0, 8);cout << setw(116)<<\
		 "┏━┓┏━┓┏━┓▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉┏━┓┏━┓┏━┓" << endl;
		Setcolor_0211adby(0, 4);cout << setw(60) << "哦!铭萌雏欣提醒您|当前购物车为空|请选购商品!哒" << endl;
		Setcolor_0211adby(0, 8);cout << setw(116) <<\
		 "┏━┓┏━┓┏━┓▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉┏━┓┏━┓┏━┓" << endl;
		 PauseClear_0211adby();
		return ;
	} Setcolor_0211adby(0, 5);   // 紫色字体
	cout << "账单如下: " << endl;
	PX_0211adby->article_0211adby.AccountExample_0211adby();
	Setcolor_0211adby(0, 11);  // 淡浅绿色
	while(PX_0211adby){
		PX_0211adby->article_0211adby.Account_0211adby();
		money_0211adby += PX_0211adby->article_0211adby.OneAccount_0211adby();
		PX_0211adby = PX_0211adby->next;
	}
	Setcolor_0211adby(0, 5);   // 紫色字体 
	cout << endl << endl;
	cout << setw(40) << "您应该支付金额为: "  << fixed << setprecision(2) << money_0211adby << "元" << endl; 
	Setcolor_0211adby(0, 7);   // 白色字体 
	ShowTime_0211adby();
	while(*HeadCart_0211adby){
		PX_0211adby = *HeadCart_0211adby;
		*HeadCart_0211adby = (*HeadCart_0211adby)->next;
		delete PX_0211adby;
	}
	Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
	Setcolor_0211adby(0, 5);cout << setw(50) << "哦!成功退出结账服务!哒" << endl;
	Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
	PauseClear_0211adby();
}

void AddGoods_0211adby(SaveGoods_0211adby** HeadSave_0211adby)		// 添加超市新货物信息 函数 
{
	SaveGoods_0211adby** Head_0211adby = HeadSave_0211adby;
	SaveGoods_0211adby* p1_0211adby = *Head_0211adby;
	SaveGoods_0211adby* p2_0211adby = *Head_0211adby;
	SaveGoods_0211adby* traverse_0211adby = *Head_0211adby; 	 	// 必须初始化 
	
	char GoodsId_0211adby[20];		
	char GoodsName_0211adby[30];
	char GoodsPrice_0211adby[20];
	int flag_0211adby = 0;
	
	while(p1_0211adby){
		p2_0211adby = p1_0211adby;
		p1_0211adby = p1_0211adby->next;
	}	
	while(1)
	{Setcolor_0211adby(0, 10);  // 绿色字体 
		cout << "注意依次输入 0 0 0 停止录取商品信息!" << endl;
		cout << setw(50)<< "请输入商品条形码号: ";Setcolor_0211adby(0, 9); cin >> GoodsId_0211adby; cout <<  endl; Setcolor_0211adby(0, 10);
		cout << setw(50)<< "请输入商品名称: ";Setcolor_0211adby(0, 9); cin >> GoodsName_0211adby; cout <<  endl;Setcolor_0211adby(0, 10);
		cout << setw(50)<< "请输入商品价格: ";Setcolor_0211adby(0, 9); cin >> GoodsPrice_0211adby; cout <<  endl;
		if(JudgeId_0211adby(GoodsId_0211adby) == -1)	{
			cout << endl << endl;Setcolor_0211adby(0, 3);cout <<setw(27) <<  "┭┮﹏┭┮";
			Setcolor_0211adby(0, 4);	cout<<" 条形码号输入错误";Setcolor_0211adby(0, 9);cout<<" O(∩_∩)O" << endl;
			PauseClear_0211adby();
			continue; 
		}else if(JudegPrice_0211adby(GoodsPrice_0211adby) == -1){
			cout << endl << endl;Setcolor_0211adby(0, 3);cout <<setw(27) <<  "┭┮﹏┭┮";
			Setcolor_0211adby(0, 4);	cout<<" 单价输入错误";Setcolor_0211adby(0, 9);cout<<" O(∩_∩)O" << endl;
			PauseClear_0211adby();
			continue;
		}	
		if(JudgeId_0211adby(GoodsId_0211adby) == 0){
			Setcolor_0211adby(0, 8);cout << setw(90)<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
			Setcolor_0211adby(0, 4);cout << setw(55) << "哦!铭萌雏欣提醒您|新商品添加完成!哒" << endl;
			Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
			PauseClear_0211adby();
			break;
		}
		while(traverse_0211adby){	
			if(traverse_0211adby->articleIfno_0211adby.GetId_0211adby() == JudgeId_0211adby(GoodsId_0211adby))
			{	cout << endl << endl; Setcolor_0211adby(0, 14);	cout << setw(30)<< "↓↓|→→|";
				Setcolor_0211adby(0, 2);	cout<<" 嘿哈,请看下面信息";Setcolor_0211adby(0, 14);	cout<<" |←←|↓↓" << endl << endl;
				Setcolor_0211adby(0, 9u); cout << setw(81) << "☆ ☆ ☆ ☆ 铭萌雏欣小超市 ☆ ☆ ☆ ☆" << endl << endl;
				traverse_0211adby->articleIfno_0211adby.Id_Show(JudgeId_0211adby(GoodsId_0211adby));
				cout << endl << endl;	Setcolor_0211adby(0, 14);	cout<< setw(20) << "↑↑|→→|";
				Setcolor_0211adby(0, 4); cout<<" 该条形码号已经使用过啦,请输入新的条形码号哦"; Setcolor_0211adby(0, 14);
				cout<<" |←←|↑↑" << endl;
				PauseClear_0211adby();
				flag_0211adby = 1; 
				break; 
			}
			traverse_0211adby = traverse_0211adby->next;
		} 
		if(flag_0211adby){	
			flag_0211adby = 0;
			traverse_0211adby = *Head_0211adby;
			continue;
		}
		p1_0211adby = new SaveGoods_0211adby;
		if(*Head_0211adby){	
			p2_0211adby->next = p1_0211adby;
			p2_0211adby = p1_0211adby;
		}else{
			*Head_0211adby = p2_0211adby = p1_0211adby;
		}
	
		p1_0211adby->articleIfno_0211adby.ModifyInfo_0211adby(JudgeId_0211adby(GoodsId_0211adby), GoodsName_0211adby, JudegPrice_0211adby(GoodsPrice_0211adby));
		p2_0211adby->next = NULL;
		traverse_0211adby = *Head_0211adby;
//		system("cls");
		 cout << endl << endl;
		Setcolor_0211adby(0, 12);cout << setw(30) << "成功添加";	Setcolor_0211adby(0, 14);	cout << " ▉▉▉▉▉▉  ";
		Setcolor_0211adby(0, 10);cout  <<GoodsName_0211adby; Setcolor_0211adby(0, 14);cout << "  ▉▉▉▉▉▉";
		Setcolor_0211adby(0, 12);cout << " 到 "; Setcolor_0211adby(0, 9u);cout<<"☆ ☆ ☆ ☆ 铭萌雏欣小超市 ☆ ☆ ☆ ☆"<<endl; 
		PauseClear_0211adby();
	}
	if(p2_0211adby)
		p2_0211adby->next = NULL;
}
void ShowCartInfo_0211adby(Purchase_0211adby**  HeadPurchase_0211adby)  // 显示购物车中商品信息 
{
	Purchase_0211adby *Head_0211adby = *HeadPurchase_0211adby;
	Purchase_0211adby *P_0211adby = Head_0211adby;
	if(!Head_0211adby){	
		cout << endl << endl;
		Setcolor_0211adby(0, 8);cout << setw(90)	<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
		Setcolor_0211adby(0, 4);cout << setw(55) << "哦!铭萌雏欣提醒您|当前购物车为空!哒" << endl;
		Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
		PauseClear_0211adby();
		return ;
	}
	Head_0211adby->article_0211adby.AccountExample_0211adby();
	Setcolor_0211adby(0, 11);  // 淡绿色字体 
	while(P_0211adby)
	{
		P_0211adby->article_0211adby.Account_0211adby();
		P_0211adby = P_0211adby->next;
	}
	PauseClear_0211adby();
}
void DeleteGoods_0211adby(SaveGoods_0211adby** HeadSave_0211adby)
{
	SaveGoods_0211adby** Head_0211adby = HeadSave_0211adby;
	SaveGoods_0211adby* Last_0211adby = *HeadSave_0211adby;
	SaveGoods_0211adby* p_0211adby = *HeadSave_0211adby;
	SaveGoods_0211adby* p2_0211adby = NULL;
	SaveGoods_0211adby* pFront_0211adby = *HeadSave_0211adby;
	
	char id_0211adby[20];
	int flag_0211adby = 1;
	
	if(!p_0211adby){
		Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
		Setcolor_0211adby(0, 4);cout << setw(50) << "哦!铭萌雏欣|没有商品!呢" << endl;
		Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
		PauseClear_0211adby();
		return ;
	}
	Setcolor_0211adby(0, 2);		// 绿色字体 
	cout << setw(50) << "请输入要删掉商品的条形码号: ";Setcolor_0211adby(0, 9);
	cin >> id_0211adby;
	if(JudgeId_0211adby(id_0211adby) == -1)
	{	cout << endl << endl;Setcolor_0211adby(0, 3);cout <<setw(27) <<  "┭┮﹏┭┮";
		Setcolor_0211adby(0, 4);	cout<<" 条形码号输入错误";Setcolor_0211adby(0, 9);cout<<" O(∩_∩)O" << endl;
		PauseClear_0211adby();
		return ; 
	}
	while(Last_0211adby)
	{
		pFront_0211adby = Last_0211adby;
		Last_0211adby = Last_0211adby->next;
	}
	Last_0211adby = pFront_0211adby;
	while(p_0211adby)
	{
		pFront_0211adby = p_0211adby;
		if(p_0211adby->articleIfno_0211adby.GetId_0211adby() == JudgeId_0211adby(id_0211adby)){
			flag_0211adby = 0;
			break;
		}
		p_0211adby = p_0211adby->next;
	}
	
	if(flag_0211adby){
	 	cout << endl << endl;
		Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
		Setcolor_0211adby(0, 4);cout << setw(50) << "哦!铭萌雏欣|没该商品!哦" << endl;
		Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
		PauseClear_0211adby();
		return ;
	}
	if(*Head_0211adby == pFront_0211adby)
	{
		*Head_0211adby = (*Head_0211adby)->next;
		delete pFront_0211adby;
	}else if(Last_0211adby == pFront_0211adby)
	{
		p_0211adby = *Head_0211adby;
		while(p_0211adby->next != pFront_0211adby && p_0211adby)
			p_0211adby = p_0211adby->next;
		p_0211adby->next = NULL;
		delete pFront_0211adby;
	}else{
		p_0211adby = *Head_0211adby;	
		p2_0211adby = *Head_0211adby;
		while(p_0211adby->next != pFront_0211adby && p_0211adby){
			p2_0211adby = p_0211adby;
			p_0211adby = p_0211adby->next;
		}
		p_0211adby = p_0211adby->next;
		p2_0211adby->next = p_0211adby->next;
		delete p_0211adby;
	}
	
	cout << endl << endl;
	Setcolor_0211adby(0, 8);cout << setw(90)<< "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
	Setcolor_0211adby(0, 4);cout << setw(55) << "哦!铭萌雏欣提醒您|商品信息已删除!哒" << endl;
	Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
}
void SortGoods_0211adby(SaveGoods_0211adby** HeadSave_0211adby) // 超市商品按条形码进行升序排序
{
	SaveGoods_0211adby** Head_0211adby = HeadSave_0211adby;
	SaveGoods_0211adby* p1_0211adby = *Head_0211adby;
	SaveGoods_0211adby* p2_0211adby = *Head_0211adby;	
	SaveGoods_0211adby* ptemp_0211adby = NULL;
	
	if(!*Head_0211adby){
		cout << endl << endl;
		Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
		Setcolor_0211adby(0, 4);cout << setw(50) << "哦!铭萌雏欣|没该商品!呢" << endl;
		Setcolor_0211adby(0, 8);cout << setw(87)<< "▉▉▉▉▉▉●┏━┓┏━┓┏━┓o┏━┓┏━┓┏━┓●▉▉▉▉▉▉" << endl;
		PauseClear_0211adby();
		return ;
	}
	else{
		Setcolor_0211adby(0, 2);cout << setw(116)<< "●┏━┓┏━┓┏━┓▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉●┏━┓┏━┓┏━┓" << endl;
		Setcolor_0211adby(0, 3);cout << setw(53) << "哦!铭萌雏欣诚挚歉意|此项服务尚未完成!哒" << endl;
		Setcolor_0211adby(0, 2);cout << setw(116) << "●┏━┓┏━┓┏━┓▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉●┏━┓┏━┓┏━┓" << endl;
		PauseClear_0211adby();
		return ;
	}
	
	SaveGoods_0211adby* last_0211adby = NULL;
	while(p1_0211adby){
		last_0211adby = p1_0211adby;
		p1_0211adby = p1_0211adby->next;
	}
	p1_0211adby = *Head_0211adby;
	for( ; p1_0211adby ; p1_0211adby = p1_0211adby->next){
		for(p2_0211adby = p1_0211adby->next; p2_0211adby; p2_0211adby = p2_0211adby->next){
			if(p1_0211adby->articleIfno_0211adby.GetId_0211adby() > p2_0211adby->articleIfno_0211adby.GetId_0211adby())
			{
				ptemp_0211adby = p1_0211adby;
				p1_0211adby = p2_0211adby;
				p2_0211adby = ptemp_0211adby;
			}
		}
	}
}
void GoodsBarcodeAsc_0211adby(SaveGoods_0211adby** HeadSave_0211adby)
{
	if(! *HeadSave_0211adby){ printf("不存在该链表\n");	return ; }
	if(! (*HeadSave_0211adby)->next){ PauseClear_0211adby();	 return ;}
	
	SaveGoods_0211adby** Head_0211adby = HeadSave_0211adby;
	SaveGoods_0211adby* pre_0211adby = NULL;
	SaveGoods_0211adby* p1_0211adby = *Head_0211adby;
	SaveGoods_0211adby* p2_0211adby = (*Head_0211adby)->next;
	
	SaveGoods_0211adby* NewHead_0211adby = NULL;
	SaveGoods_0211adby* Np_0211adby;
	SaveGoods_0211adby* temp_0211adby = NULL; 
	
	while(p1_0211adby->next)
	{
		p2_0211adby = p1_0211adby->next;
		
		pre_0211adby = p1_0211adby;
		temp_0211adby = p1_0211adby;
		while(p2_0211adby)
		{
			if(p1_0211adby->articleIfno_0211adby.GetId_0211adby() > p2_0211adby->articleIfno_0211adby.GetId_0211adby()){
				temp_0211adby = p2_0211adby;
			}
			if(p1_0211adby->next != p2_0211adby)
				pre_0211adby = pre_0211adby->next;		
			p2_0211adby = p2_0211adby->next;	
		}
		if(!NewHead_0211adby){
			if(temp_0211adby == p1_0211adby){
				NewHead_0211adby = temp_0211adby;
				p1_0211adby = p1_0211adby->next;
			} else{
				NewHead_0211adby = temp_0211adby;
				pre_0211adby->next = temp_0211adby->next;
			}
			Np_0211adby = NewHead_0211adby;
		}else{
			if(temp_0211adby == p1_0211adby){
				Np_0211adby->next = temp_0211adby;
				p1_0211adby = p1_0211adby->next;
			} else{
				Np_0211adby->next = temp_0211adby;
				pre_0211adby->next = temp_0211adby->next;
			}
		}
			Np_0211adby = temp_0211adby;
	}
	if(p1_0211adby == temp_0211adby->next)
		Np_0211adby->next = pre_0211adby->next;
	else
		Np_0211adby->next =  pre_0211adby;
	Np_0211adby->next->next = NULL;
	*HeadSave_0211adby = NewHead_0211adby;
	cout << "排序完成"	<< endl;
	PauseClear_0211adby();
}
void SelectMenu_0211adby(SaveGoods_0211adby** HeadSave_0211adby, Purchase_0211adby** HeadPurchase_0211adby)		// 选择菜单服务函数 的 定义 
{
	SaveGoods_0211adby** Head_0211adby = HeadSave_0211adby;
	Purchase_0211adby** HeadB_0211adby = HeadPurchase_0211adby;
	int quit_0211adby = 0;
	char select_0211adby[15];
	WelcomeSupermarket_0211adby();
	
	PauseClear_0211adby();
	while(1)
	{	
		Setcolor_0211adby(0, 7);   // 白色字体 
		ShowTime_0211adby();
		ShowMenu_0211adby();
		
		Setcolor_0211adby(0, 2);   // 绿色字体 
		cout << "请输入你选择的功能>>  ";
		cin >> select_0211adby;
		Clear_0211adby();	
		switch(JudgeSelect_0211adby(select_0211adby))
		{	
			case 0: quit_0211adby = Release_0211adby(Head_0211adby, HeadB_0211adby); break;		// 退出超市 
			case 1: CreatGoodsInfo(Head_0211adby); break;		// 建立超市商品信息库 
			case 2: DeleteGoods_0211adby(Head_0211adby); break;		// 删除超市有关商品信息 
			case 3: AddGoods_0211adby(Head_0211adby); break;			// ModifyGoodsInfo(Head_0211adby);cout << "尚未开发此功能" << endl 
			case 4: ShowInfo_0211adby(Head_0211adby); break;	// 查看超市商品信息 
			case 5: ShowAll_0211adby(Head_0211adby); break;	// 查看超市所有商品信息 
			case 6: SortGoods_0211adby(Head_0211adby);  break; // 6: 超市商品按条形码进行升序排序
			case 7: Trolley_0211adby(Head_0211adby, HeadB_0211adby);  break;	// 购物车选购服务 
			case 8: ShowCartInfo_0211adby(HeadB_0211adby);  break ;		// 显示购物车中商品信息 
			case 9: Check_0211adby(HeadB_0211adby); break;				// 结算购物车 
			case 10:GoodsBarcodeAsc_0211adby(Head_0211adby); break;		// 超市货物按条形码按整合排序 
			default: Setcolor_0211adby(0, 4); 
				cout << endl << endl;
				Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				Setcolor_0211adby(0, 4);cout << setw(50) << "哦!没该选项|服务失败!哒" << endl;
				Setcolor_0211adby(0, 8);cout << setw(90) << "▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉" << endl;
				PauseClear_0211adby();
		}
		if(quit_0211adby)	break;	
	}
	LeaveSupermarket_0211adby();
	Setcolor_0211adby(0, 7);
}

long long JudgeId_0211adby(char *p)
{
	int i;
	int count = 0;
	int len = strlen(p);
	if(len > 15)
		return -1;
	long long id = 0;
	for(i = 0; p[i] != '\0'; i++)
		if(p[i] >= '0' && p[i] <= '9'){
			count += 1;
			id = id * 10 +  (p[i] - '0');
		}
	if(count != len)
		return -1;
	return id;
} 
float JudegPrice_0211adby(char *p)
{
	int i, j = 0, z = 0;
	int count = 0;
	int len = strlen(p);
	if(len > 15)
		return -1;
	float price = 0;
	for(i = 0; p[i] != '\0' && p[i] != '.'; i++){
		if(p[i] >= '0' && p[i] <= '9'){
			count += 1;
			price = price * 10 +  (p[i] - '0');
		}
		else 	break;
	}
		
	if(p[i] == '.'){
		for(i += 1; p[i] != '\0' && j < 2; i++){
			if(p[i] >= '0' && p[i] <= '9'){
				price = price * 10 + (p[i] - '0');
				count ++; j += 1; z = 1;
			}	
		}
	}	
	if(z){
		if(count != len-1)
			return -1;
	}else if(count != len){
			return -1;
	}	
	if(j == 0)
		return price;
	else if(j == 1)
		return price / 10;
	return price / 100;
}
int JudgeSelect_0211adby(char *p)
{
	int i;
	int count = 0;
	int len = strlen(p);
	if(len > 3)
		return -1;
	int select = 0;
	for(i = 0; p[i] != '\0'; i++)
		if(p[i] >= '0' && p[i] <= '9'){
			count += 1;
			select = select * 10 +  (p[i] - '0');
		}
	if(count != len)
		return -1;
	return select;
} 
void ShowTime_0211adby(void)
{
	time_t rawtime_0211adby;		// 定义一个代表日历时间的变量
	struct tm *timeinfo_0211adby = NULL;		// 定义一个指向 tm结构 变量的指针 并赋值为 NULL 
	
	rawtime_0211adby = time(&rawtime_0211adby);
	timeinfo_0211adby = localtime(&rawtime_0211adby);	// 获取当前的日历时间值
	 
	cout << timeinfo_0211adby->tm_year + 1900 << "年"  << setw(2) << setfill('0') << timeinfo_0211adby->tm_mon << "月" << setw(2)  << timeinfo_0211adby->tm_mday <<"日" << ' '\
	<< setw(2)<< timeinfo_0211adby->tm_hour <<  ':'  << setw(2)<<timeinfo_0211adby->tm_min << ':' << setw(2) << timeinfo_0211adby->tm_sec << setfill(' ') << endl; 	
}
void WelcomeSupermarket_0211adby(void)
{
	Setcolor_0211adby(0, 11);  // 浅绿色字体 
	cout << endl << endl;
	cout <<  setw(85)<< "(*^▽^*)☆ ☆ ☆ ☆ 铭萌雏欣小超市 ☆ ☆ ☆ ☆(*^▽^*)" << endl<< endl ;
	cout<<"                                                //==\\\\" << endl;
	cout<<"                                               /.....|"<< endl;	Setcolor_0211adby(0, 12);
	cout<<"                                              |......|"<< endl;
	cout<<"                                              |......|      ==\\\\"<< endl;
	cout<<"	         //=...\\\\\\=......=========    |...../     /....\\|"<< endl;	Setcolor_0211adby(0, 2);
	cout<<"	       //........\\\\................===\\\\..//     /......|"<< endl;
	cout<<"	     //...........||......./===\\........\\\\\\\\     |......|"<< endl;	
	cout<<"	     ||.@@.........|.....//     \\..........\\\\\\  |....../"<< endl;Setcolor_0211adby(0, 13);
	cout<<"	     |........@@..||.....|   @@  |.//   \\\\....=\\|\\...//"<< endl;
	cout<<"	     ||.........../......\\  @  //||      ||.......\\\\\\"<< endl;
	cout<<"	      \\........//.........\\===/..||  @@@ ||..........\\\\"<< endl;	Setcolor_0211adby(0, 3);
	cout<<"	        \\====//...................\\\\ =///............\\\\"<< endl;
	cout<<"	           \\\\\\...........................................\\\\"<< "     嗨嗨嗨,欢迎光临铭萌欣雏小商店" <<endl;
	cout<<"	             \\\\\\..........................................\\\\"<< endl;
	cout<<"	                \\\\\\..............................!!!!!....|"<< endl;	Setcolor_0211adby(0, 5);
	cout<<"	                    ||..........................!!!!!!!!!..||"<< endl;
	cout<<"	                    |..........................!!!!!!!!!!!..|"<< endl;
	cout<<"	                    |....|.....................!!!!!!!!!!!..|"<< endl;		Setcolor_0211adby(0, 6);
	cout<<"	                    |..........................!!!!!!!!!!...|"<< endl;
	cout<<"	                    ||....\\\\....................!!!!!!!....||"<< endl;
	cout<<"	                     |......\\\\........../..................|"<< endl;  Setcolor_0211adby(0, 7);
	cout<<"	                     \\\\.......\\======/....................//"<< endl;
	cout<<"	                      \\\\.................................//"<< endl;
	cout<<"	                        \\\\.............................//"<< endl;	Setcolor_0211adby(0, 8);
	cout<<"	                         \\\\...........................//"<< endl;
	cout<<"	                           \\\\\\.....................///"<< endl;	Setcolor_0211adby(0, 9);
	cout<<"	                              \\\\\\=.............=///"<< endl;
	cout<<"	                                   ==========="<< endl<<endl;		Setcolor_0211adby(0, 10);
	cout<<setw(72)<<"超市里面没有库存啦,可以先建立库存再进行选购哦"<< endl << endl;Setcolor_0211adby(0, 14);
    cout<<setw(64)<<"温馨提示:按任意键进入超市后台" << endl; 	Setcolor_0211adby(0, 15);
	cout<<setw(78)<<"请您注意相关事项: 文字输入不得超过15字,数字输入不得超过15位"; 
}
void LeaveSupermarket_0211adby(void)
{
	Setcolor_0211adby(0, 11);  // 浅绿色字体 
	cout << endl << endl;
	cout <<  setw(85)<< "(*^▽^*)☆ ☆ ☆ ☆ 铭萌雏欣小超市 ☆ ☆ ☆ ☆(*^▽^*)" << endl<< endl ;
	cout<<"                                                //==\\\\" << endl;
	cout<<"                                               /.....|"<< endl;	Setcolor_0211adby(0, 12);
	cout<<"                                              |......|"<< endl;
	cout<<"                                              |......|      ==\\\\"<< endl;
	cout<<"	         //=...\\\\\\=......=========    |...../     /....\\|"<< endl;	Setcolor_0211adby(0, 2);
	cout<<"	       //........\\\\................===\\\\..//     /......|"<< endl;
	cout<<"	     //...........||......./===\\........\\\\\\\\     |......|"<< endl;	
	cout<<"	     ||.@@.........|.....//     \\..........\\\\\\  |....../"<< endl;Setcolor_0211adby(0, 13);
	cout<<"	     |........@@..||.....|   @@  |.//   \\\\....=\\|\\...//"<< endl;
	cout<<"	     ||.........../......\\  @  //||      ||.......\\\\\\"<< endl;
	cout<<"	      \\........//.........\\===/..||  @@@ ||..........\\\\"<< endl;	Setcolor_0211adby(0, 3);
	cout<<"	        \\====//...................\\\\ =///............\\\\"<< endl;
	cout<<"	           \\\\\\...........................................\\\\"<< "     嗨嗨嗨,再见了铭萌欣雏小商店" <<endl;
	cout<<"	             \\\\\\..........................................\\\\"<< endl;
	cout<<"	                \\\\\\..............................!!!!!....|"<< endl;	Setcolor_0211adby(0, 5);
	cout<<"	                    ||..........................!!!!!!!!!..||"<< endl;
	cout<<"	                    |..........................!!!!!!!!!!!..|"<< endl;
	cout<<"	                    |....|.....................!!!!!!!!!!!..|"<< endl;		Setcolor_0211adby(0, 6);
	cout<<"	                    |..........................!!!!!!!!!!...|"<< endl;
	cout<<"	                    ||....\\\\....................!!!!!!!....||"<< endl;
	cout<<"	                     |......\\\\........../..................|"<< endl;  Setcolor_0211adby(0, 7);
	cout<<"	                     \\\\.......\\======/....................//"<< endl;
	cout<<"	                      \\\\.................................//"<< endl;
	cout<<"	                        \\\\.............................//"<< endl;	Setcolor_0211adby(0, 8);
	cout<<"	                         \\\\...........................//"<< endl;
	cout<<"	                           \\\\\\.....................///"<< endl;	Setcolor_0211adby(0, 9);
	cout<<"	                              \\\\\\=.............=///"<< endl;
	cout<<"	                                   ==========="<< endl<<endl;		Setcolor_0211adby(0, 10);	//	return ; 
}
void PauseClear_0211adby(void)
{
	getch();
	system("cls");
} 
void Pause_0211adby(void)
{
	getch();
}
void Clear_0211adby(void)
{
	system("cls");
}


2️⃣⏺️1️⃣🦉校园导游系统(字符界面)🧸

|*🐧程序2.1:超市管理系统🧸*|

//#include <bits/stdc++.h>
#include<iostream>
#include<cstring>
//#include<iosfwd>		//	文件操作 
#include <fstream> 		//  variable 'std::ofstream passwordFile' has initializer but incomplete type
using namespace std;
#define MAXV  30		// 最大顶点数 
#define INF 66666		// 纯粹两个点不可达(最大为 666666) 

typedef struct {		// 存放顶的的信息 
	int no;				// 顶点编号 
	string location;	// 地方名称
	string scenery;		// 地方景色 
} VertexType;

typedef struct {
	int arcs[MAXV][MAXV];	// 邻接矩阵数组 
	int vexnum, arcsnum;	// 顶点(景点)数量 , 边数量 
	VertexType vex[MAXV];	// 存放顶点信息 
} MGraph;

char adminPassword[20] = "admin";	// 管理员默认密码 
int speed = 78;					// 大学生平均每分钟步行距离 
bool origin = false;			// 景点信息未更改 

void CreateMGraph(MGraph &G) {
    G.vexnum = 19;			// 初始化景点的个数 
    for(int i = 1; i <= G.vexnum; i++)	// 每个景点设置一个编号 
        G.vex[i].no = i;
    
    for(int i = 1; i <= G.vexnum; i++)	// 初始化邻接矩阵
    {
    	for(int j = 1; j <= G.vexnum; j++)
            G.arcs[i][j] = INF;
        G.arcs[i][i] = 0;
	}
    /* 初始化景点名称和景点介绍  */
    G.vex[1].location = "南门";				G.vex[1].scenery = "作为学校的主要出入口之一,南门是本校的象征之一,展现着学校的精神风貌!";
    G.vex[2].location = "第一教学楼";		G.vex[2].scenery = "坐落在校园中心的第一教学楼是学生们上课、学习的重要场所,设有多个教室和多媒体教室,方便师生进行各类教学活动!";
	G.vex[3].location = "第二教学楼";		G.vex[3].scenery = "紧邻第一教学楼的第二教学楼也是学校重要的教学楼之一,设施齐备,提供优质的学习环境!";
	G.vex[4].location = "第一食堂";			G.vex[4].scenery = "位于校园内,第一食堂提供丰富的菜品选择,满足广大师生的饮食需求!";
	G.vex[5].location = "图书馆";			G.vex[5].scenery = "本校的图书馆是一个宽敞明亮的学习场所,拥有丰富的中外文图书和电子资源,为学生提供良好的阅读和研究环境!";
	G.vex[6].location = "实验楼";			G.vex[6].scenery = "该楼设有多个实验室,供学生进行科研及实践活动,为学生提供了实践技能培养的平台!";
	G.vex[7].location = "教学科研楼";		G.vex[7].scenery = "该楼是进行各种理论和实践教学的主要场所,它配备了现代化的实验设备和教学工具,为学生提供了良好的学术交流平台!";
	G.vex[8].location = "东门";				G.vex[8].scenery = "东门是学校的另一个出入口,沿着东门可通往校外的交通枢纽,提供方便的交通接驳条件!";
	G.vex[9].location = "静苑";				G.vex[9].scenery = "静苑是学校内一片风景优美的院落,花草绿树环绕,是学生休闲放松的好去处!";
	G.vex[10].location = "雅苑";			G.vex[10].scenery = "雅苑是学校的一片安静区域,有宽敞的草坪和凉亭,供学生们休息和娱乐!";
	G.vex[11].location = "西操场";			G.vex[11].scenery = "西操场是学校体育活动的主要场所,包括篮球、足球等运动设施,为学生提供了锻炼身体和丰富课余生活的机会!";
	G.vex[12].location = "第二餐厅";		G.vex[12].scenery = "位于校园内,第二餐厅提供多种美食选择,满足师生的饮食需求!";
	G.vex[13].location = "西门";			G.vex[13].scenery = "西门是学校的另一个出入口,沿着西门可通往周边商圈和居民区!";
	G.vex[14].location = "北门";			G.vex[14].scenery = "位于校园北侧的北门是学校的出入口之一,连接校园与周边社区!";
	G.vex[15].location = "怡苑";			G.vex[15].scenery = "怡苑是学校内一处景色宜人的院落,有花坛和绿化带,给人以宁静和愉悦的感觉!";
	G.vex[16].location = "第三餐厅";		G.vex[16].scenery = "第三餐厅提供多个餐厅区域,供师生就餐,菜品种类齐全,满足不同口味的需求!";
	G.vex[17].location = "菜鸟驿站";		G.vex[17].scenery = "学校设有菜鸟驿站,方便学生代收快递和便捷寄送包裹!";
	G.vex[18].location = "东操";			G.vex[18].scenery = "东操是学校体育活动的重要场所,设有运动场地和健身器材,为学生提供了锻炼身体和娱乐放松的场所!";
	G.vex[19].location = "体育馆";			G.vex[19].scenery = "学校的体育馆是举办大型体育赛事和文艺演出的场所,设施齐备,可容纳大量观众!";
	
    G.arcs[1][2]= G.arcs[2][1] = 338;		/* 根据大概估算设置的两点距离 */ 
    G.arcs[1][3]=G.arcs[3][1]=338;
	G.arcs[1][5]=G.arcs[5][1]=452;
	G.arcs[2][4]=G.arcs[4][2]=110;
	G.arcs[2][5]=G.arcs[5][2]=200;
	G.arcs[3][5]=G.arcs[5][3]=200;
	G.arcs[3][6]=G.arcs[6][3]=80;
	G.arcs[4][5]=G.arcs[5][4]=225;
	G.arcs[4][9]=G.arcs[9][4]=55;
	G.arcs[5][6]=G.arcs[6][5]=225;
	G.arcs[5][7]=G.arcs[7][5]=175;
	G.arcs[5][9]=G.arcs[9][5]=250;
	G.arcs[5][12]=G.arcs[12][5]=375;
	G.arcs[5][16]=G.arcs[16][5]=450;
	G.arcs[6][7]=G.arcs[7][6]=120;
	G.arcs[6][8]=G.arcs[8][6]=160;
	G.arcs[7][8]=G.arcs[8][7]=325;
	G.arcs[7][16]=G.arcs[16][7]=338;
	G.arcs[8][16]=G.arcs[16][8]=447;
	G.arcs[8][18]=G.arcs[18][8]=287;
	G.arcs[9][10]=G.arcs[10][9]=55;
	G.arcs[9][12]=G.arcs[12][9]=175;
	G.arcs[10][11]=G.arcs[11][10]=30;
	G.arcs[10][12]=G.arcs[12][10]=230;
	G.arcs[11][12]=G.arcs[12][11]=140;
	G.arcs[11][14]=G.arcs[14][11]=210;
	G.arcs[12][14]=G.arcs[14][12]=350;
	G.arcs[12][15]=G.arcs[15][12]=160;
	G.arcs[12][16]=G.arcs[16][12]=250;
	G.arcs[13][14]=G.arcs[14][13]=210;
	G.arcs[14][15]=G.arcs[15][14]=338;
	G.arcs[15][16]=G.arcs[16][15]=150;
	G.arcs[15][17]=G.arcs[17][15]=20;
	G.arcs[15][19]=G.arcs[19][15]=395;
	G.arcs[16][18]=G.arcs[18][16]=120;
	G.arcs[16][19]=G.arcs[19][16]=225;
	G.arcs[18][19]=G.arcs[19][18]=50;
}

void Map() {
	cout << '\n';
	cout << "\t\t   ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n";
	cout << "\t\t   ┃\t\t院校高效学校大学 zh东校区 导航图\t      ┃\n";
	cout << "\t\t   ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n";
	cout << "\t\t              o14北门\n";
	cout << "\t\t              ┃                  o17菜鸟驿站\n";
	cout << "\t\t      13西门  ┃          15怡苑  ┃                     19体育馆\n";
	cout << "\t\t        o━━━━━┛━━━━━━━━━━━━━━━o━━┗━━━━━━━━━━━━━━━━━━━┏━━o\n";
	cout << "\t\t          ┃                   ┃                      ┃\n";
	cout << "\t\t          ┃         12二餐    ┃     16三餐           ┃ 18东操\n";
	cout << "\t\t          o 11西操      o━━━━━┗━━━━━━━━o━━━━━━━━━━━━━o\n";
	cout << "\t\t          ┗━━━━━━━━━━━━━┛                            ┃\n";
	cout << "\t\t          ┃             ┃                            ┃\n";
	cout << "\t\t          ┃ 10雅苑      ┃            7科研楼         ┃\n";
	cout << "\t\t          o             ┗━┓           o━━━┓━━━━━━━━━━o8东门\n";
	cout << "\t\t          ┃ 9静苑         ┃ 5图书馆   ┃   ┃\n";
	cout << "\t\t          ┗o━━━━━━━━━━━━━━o━━━━━━━━━━━┛   ┃\n";
	cout << "\t\t           ┃ 4一餐        ┃               ┃\n";
	cout << "\t\t           ┗o━━━━━━━━━━━━━┃━━━━━━━━━━━━┏━━o6实验楼\n";
	cout << "\t\t            ┃    2教一    ┃      3教二 ┃\n";
	cout << "\t\t            ┗━━━━o━━━━━━━━┓━━━━━━━━━━o━┛\n";
	cout << "\t\t                          ┃\n";
	cout << "\t\t                          ┃\n";
	cout << "\t\t  ┗━━━━━━━━━━━━━━━━━━━━ 1南门 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n\n";
	if(origin)
		cout << " \t\t\t    ■ ■ ■ ■ 景点数量改动注意地图未更新 ■ ■ ■ ■" << endl;
}
void Info(MGraph &G) {
	int n;
	cout<<"请输入需要查询的景点编号(1~" << G.vexnum << "):"; 
	cin>>n;
	if(0 < n && n <= G.vexnum)
		cout << G.vex[n].no << ": " << G.vex[n].location << " 地方介绍 " << G.vex[n].scenery << "\n";
	else
		cout << "哦买噶,景点编号不存在哦!\n";      
	cout << "\n请输入0返回主菜单:";
}
void Dispathall(MGraph g,int dist[],int path[],int S[],int v)	//输出从顶点v出发的所有最短路径
{	int i,j,k;
	int apath[MAXV],d;						//存放一条最短路径(逆向)及其顶点个数
	for (i=1;i<=g.vexnum;i++)				//循环输出从顶点v到i的路径
		if (S[i]==1 && i!=v)
		{	
			cout << "从" << g.vex[v].location << "到" << g.vex[i].location << "路径为: \n";
			d=0; apath[d]=i;				//添加路径上的终点
			k=path[i];
			if (k==-1)						//没有路径的情况
				cout << "无路径\n";
			else							//存在路径时输出该路径
			{	
				while (k!=v){
					d++; apath[d]=k;
					k=path[k];
				}
				d++; apath[d]=v;			//添加路径上的起点
				cout << "   " << g.vex[apath[d]].location;  // 先输出 起点 
				for (j=d-1;j>=0;j--)		//再输出其他顶点
					cout  << " -> " << g.vex[apath[j]].location;
				cout << "\n距离为: " << dist[i] << "m  所需时间为: " << int(dist[i] / speed)  << "min" << endl;
			}
		}
}
void Dispath(MGraph g,int dist[],int path[],int S[],int start, int end)
{
	
	int i, j, k;
	int apath[MAXV],d;					// 存放一条最短路径(逆向)及其顶点个数
	i = j = end; k = 0;
	if(start == end){					// 起点与终点重合 
		cout << "目的地在原地!" << endl;
		return ;
	}
	while(start != i){
		j = path[i];
		if(path[i] == -1){
			k = 0;
			break;
		}
		apath[++k] = j;
		i = j;	
	}
	if(k){
		for(i = k; i >= 1; i--)
			cout << g.vex[apath[i]].location << " -> ";
		cout << g.vex[end].location;
		cout << "\n距离为: " << dist[end] << "m  所需时间为: " << int(dist[end] / speed)  << "min" << endl;
	}else
		cout << g.vex[start].location << "!!!不可到达!!!" << g.vex[end].location;
}
void Dijkstra(MGraph g, int v, int selectno)	// Dijkstra算法
{	
	int dist[MAXV],path[MAXV];
	int S[MAXV];				// S[i]=1表示顶点i在S中, S[i]=0表示顶点i在U中
	int Mindis,i,j,u;
	for (i=1;i<=g.vexnum;i++){
		dist[i]=g.arcs[v][i];	//距离初始化
		S[i]=0;					//S[]置空
		if (g.arcs[v][i]<INF)	//路径初始化
			path[i]=v;			//顶点v到顶点i有边时,置顶点i的前一个顶点为v
		else
			path[i]=-1;			//顶点v到顶点i没边时,置顶点i的前一个顶点为-1
	}
	S[v]=1;path[v]=0;			//源点编号v放入S中
	for (i=1;i<=g.vexnum-1;i++)	//循环直到所有顶点的最短路径都求出
	{	Mindis=INF;				//Mindis置最大长度初值
		for (j=1;j<=g.vexnum;j++)		//选取不在S中(即U中)且具有最小最短路径长度的顶点u
			if (S[j]==0 && dist[j]<Mindis){
				u=j;
				Mindis=dist[j];
			}
		S[u]=1;					//顶点u加入S中
		for (j=1;j<=g.vexnum;j++)		//修改不在S中(即U中)的顶点的最短路径
			if (S[j]==0)
				if (g.arcs[u][j]<INF && dist[u]+g.arcs[u][j]<dist[j]){
					dist[j]=dist[u]+g.arcs[u][j];
					path[j]=u;
				}
	}
	if(selectno)	// 输出起始景点可到目的地景点的最短路径
	{
		cout << "从 " << g.vex[v].location << " 出发到 " << g.vex[selectno].location << " 最短路径为\n";
		Dispath(g, dist, path, S, v, selectno); 
	}else{
		cout << "最短路径为:";
		Dispathall(g, dist, path, S, v);	// 输出该景点可达其余每个景点的最短路径
	}	
}

void dispTourMenu()
{
    cout << "\n\n";
    cout << "\t         ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ 欢迎使用院校高效学校大学导航图系统 ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆\n";
    cout << "\t                                  0. 退出\n";
    cout << "\t                                  1. 查询起点到终点路径\n";
    cout << "\t                                  2. 该点可到其余各点的信息\n";
    cout << "\t                                  3. 地点信息简介\n";
    cout << "\t                                  4. 查看地图\n";
    cout << "请输入您的选择:";
}
void touristMenu(MGraph &G)
{
    int choice; 
	int start, end;
	while(true){
		dispTourMenu();
	    cin >> choice;
	    switch (choice) {
	    	case 0:
	            return ;
	        case 1:				// 在这里执行查询地点路径的功能
	            cout << "请输入 起始 景点编号:";
	            cin >> start;
	            cout << "请输入 终点 景点编号:";
	            cin >> end;
	            if(start >= 1 && start <= G.vexnum && end >= 1 && end <= G.vexnum) {
	                Dijkstra( G,start, end);
	                cout << endl;
	            }else
	                cout << "  ▲ ▲ ▲ ▲ !无效的景点编号!请确保输入的编号在 1 到" << G.vexnum << " 之间! ▲ ▲ ▲ ▲\n";
	            break;
	        case 2:				// 从起点开始到其余点的 
	            cout << "请输入起始景点编号:";
	            cin >> start;
	            if(start >= 1 && start <= G.vexnum) {
	                Dijkstra( G,start, 0);
	                cout << endl;
	            }else
	                cout << "  ▲ ▲ ▲ ▲ !无效的景点编号!请确保输入的编号在 1 到" << G.vexnum << " 之间! ▲ ▲ ▲ ▲\n";
	            break;
	        case 3:
	            Info(G);						// 在这里执行地点信息简介的功能
	            break;
			case 4:	Map(); break; 			// 查看地图 
	        default:
	            cout << "\t\t\t\t      ▲ ▲ ▲ ▲ 无效选择  ▲ ▲ ▲ ▲\n"; 
	            break; 
    	}	
	}
}

void ChangePassword() {									//能够保存密码的函数
    char oldPass[20], newPass[20];
    while(true){
    	cout << "请输入原密码 >>  ";
	    cin >> oldPass;
	    if (strcmp(oldPass, adminPassword) == 0) {
	        cout << "请输入新密码(至少5位数)>>  ";
	        cin >> newPass;
	        if(strlen(newPass)>=5){	 
		        strcpy(adminPassword, newPass);
		        cout << "密码更改成功!\n";
		        ofstream passwordFile("password.txt");		// 将新密码保存到文件
		        passwordFile << adminPassword;
		        passwordFile.close();
		        break;
			}else
				cout << "\t\t\t      !!!新密码长的至少5位数,更改失败!!!\n";
	    }else {
	    	if(!(oldPass[0] - '0')) return ;
			    cout << " \t\t\t    !!!! ▲ ▲ ▲ ▲ 原密码错误  ▲ ▲ ▲ ▲ !!!!\n";
				cout << "\t\t\t\t     (●'?'●) 输入 0 退出 (●'?'●)\n"; 
	    }
	}
}

void Addscenery(MGraph &G) {
    if (G.vexnum >= MAXV) {
        cout << "已达到景点数量上限,无法添加新的景点!\n";
        return ;
    }
    cout << "请输入新景点的名称 >>  ";
    string name;
    cin >> name;
	G.vexnum++;
	if(!origin) origin = true; 
    G.vex[G.vexnum].location = name;
    G.vex[G.vexnum].no = G.vexnum;
    for (int i = 1; i <= G.vexnum; i++) {
        G.arcs[G.vexnum][i] = INF;
        G.arcs[i][G.vexnum] = INF;
    }
    cout <<"第 "<< G.vexnum << " 号景点添加成功!\n";
}

void Modifylocation(MGraph &G) {
    int num;
    cout << "请输入要修改的景点编号:";
    cin >> num;
    if(num >= 1 && num <= G.vexnum) {
        cout << "当前景点名称为:" << G.vex[num].location << endl;
        cout << "请输入新的景点名称(若不修改输入 n):";
        string newName;
        cin >> newName;
        if(newName[0] == 'n')
        	cout << "景点名称未修改!\n";
        else{
        	G.vex[num].location = newName;
        	cout << "景点名称修改成功!\n";
		}
    	cout << "请输入景点的介绍信息(若不修改输入 n) >> ";
    	string newscenery;
    	cin >> newscenery;
    	if(newscenery[0] == 'n')
        	cout << "景点介绍未修改!\n";
        else{
        	G.vex[num].scenery = newscenery;
        	cout << "景点介绍修改成功!\n";
		}
    } else {
        cout << "  ▲ ▲ ▲ ▲ !无效的景点编号!请确保输入的编号在 1 到" << G.vexnum << " 之间! ▲ ▲ ▲ ▲\n";
    }
}

void NewPath(MGraph &G) {
    int v1, v2, dist;
    cout << "请输入起始景点的编号:";
    cin >> v1;
    cout << "请输入终点景点的编号:";
    cin >> v2;
    if(v1 >= 1 && v1 <= G.vexnum && v2 >= 1 && v2 <= G.vexnum) {
        cout << "当前两点之间的距离为:" << G.arcs[v1][v2] << endl;
        cout << "请输入新的距离:";
        cin >> dist;
        G.arcs[v1][v2] = dist;
        G.arcs[v2][v1] = dist;  // 无向图,所以两边都要设置
        cout << "路径添加成功!\n";
    } else {
        cout << "  ▲ ▲ ▲ ▲ !无效的景点编号!请确保输入的编号在 1 到" << G.vexnum << " 之间! ▲ ▲ ▲ ▲\n";
    }
}

void dispAdminMenu()
{
    	cout << "\n\n";
        cout << "\t\t\t   ----┏------------管理员菜单------------┓-----\r\n"; 
        cout << "\t\t\t       ┃          1. 更改密码             ┃\n";
        cout << "\t\t\t       ┃          2. 添加新的景点         ┃\n";
        cout << "\t\t\t       ┃          3. 修改景点信息         ┃\n";
        cout << "\t\t\t       ┃          4. 新建景点路径         ┃\n";
        cout << "\t\t\t       ┃          0. 返回主菜单           ┃\n";
        cout << "请输入您的选择:";
}
void AdministratorMenu(MGraph &G) {
    int choice;
    do {
    	dispAdminMenu();
        cin >> choice;
        switch(choice) {
            case 1: ChangePassword(); break;
            case 2: Addscenery(G); break;
            case 3: Modifylocation(G); break;
            case 4: NewPath(G); break;
            case 0: break;
            default: cout << "无效的选择,请重新输入!\n";
        }
    } while(choice != 0);
}

void dispmenu() {
    printf("\n\n");
    cout << "                     ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ 院校高效学校大学 ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆  ☆\n"; 
    cout << "                     ┃                       0:退出                         ┃\n";    
    cout << "                     ┃                     1:管理员登录                     ┃\n";
    cout << "                     ┃                      2:游客菜单                      ┃\n";
    cout << "                     ┃                     请选择: 0 ~ 2                     ┃\r\n"; 
    cout << "请输入你选的功能>>  "; 
}

void initpassd()
{
	ifstream passwordFile("password.txt");	// 在程序的初始化部分读取密码文件
    if (passwordFile.is_open()) {
        passwordFile >> adminPassword;
        passwordFile.close();
    }else 			      // 如果文件不存在或无法打开,可以设置一个默认密码
        strcpy(adminPassword, "admin");
}
bool loginAdmi(MGraph &G)
{
	initpassd();
	char inpassd[20];
	cout << " 请输入管理密码 >>  ";
    cin >> inpassd;
    if(strcmp(inpassd, adminPassword) == 0) {
        AdministratorMenu(G);
    } else {
        while(1) {
            cout << "\t\t     !!!! ▲ ▲ ▲ ▲ 原密码错误 (输入 0 退出)  ▲ ▲ ▲ ▲ !!!!\n";
        	cout << " 请再次输入管理密码 >>  ";
            cin >> inpassd;
            if(strcmp(inpassd, adminPassword) == 0) {
                AdministratorMenu(G); break; 
            }
            if(inpassd[0] == '0')
            	break;
        }
    }
}
void menu(MGraph &G)				// 主菜单 开始菜单 
{
    int menu_no;					// 选项号 
	while(1){
    	dispmenu(); 				// 展示主菜单选项 
    	cin >> menu_no;
        switch(menu_no) {
        	case 0:	return ;
            case 1:	loginAdmi(G);	// 管理员登录
                break;
            case 2:	touristMenu(G);	// 用户主菜单 
                break;
            default:
	            cout << "\t\t     !!!! ▲ ▲ ▲ ▲   无效选择 (请重新输入)   ▲ ▲ ▲ ▲ !!!!\n";
	            break;
        }
    }
}
int main() 
{
	MGraph G;
	CreateMGraph(G);
	menu(G);    
    return 0;
}

2️⃣⏺️2️⃣🦉校园导游系统(字符界面)[存储版本]🧸


|*🐧程序2.2:超市管理系统🧸*|

//#include <bits/stdc++.h>
#include<iostream>
#include<string.h>
//#include<iosfwd>		//	文件操作 
#include <fstream> 		//  variable 'std::ofstream passwordFile' has initializer but incomplete type
using namespace std;
//#include<stdio.h>
#define MAXV  30		// 最大顶点数 
#define MAXSITE 30
#define MAXSIGHT 150
#define INF 55555		// 纯粹两个点不可达(最大为 55555) 

typedef struct {		// 存放顶的的信息 
	unsigned short no;		// 顶点编号 
	char location[MAXSITE];	// 地方名称
	char scenery[MAXSIGHT];	// 地方景色 
} VertexType;

typedef struct {
	unsigned short arcs[MAXV][MAXV];	// 邻接矩阵数组 
	unsigned short vexnum; unsigned short arcsnum;	// 顶点(景点)数量 , 边数量 
	VertexType vex[MAXV];	// 存放顶点信息 
} MGraph;

char adminPassword[20] = "admin";	// 管理员默认密码 
int speed = 78;					// 大学生平均每分钟步行距离 
bool origin = false;			// 景点信息未更改 

void saveMGraph(MGraph &G, const char* file)
{
	FILE* fp;
	if( (fp = fopen(file, "w")) == NULL ){
		printf("File open error!\n"); 
		return ;
	}
	fwrite(&G, sizeof(G), 1, fp);
	fclose(fp);
}

void CreateMGraph(MGraph &G) {
	int j;
    G.vexnum = 19;			// 初始化景点的个数 
    for(int i = 1; i < MAXV; i++)	// 每个景点设置一个编号 
        G.vex[i].no = i;
    
    for(int i = 1; i < MAXV; i++)	// 初始化邻接矩阵
    {
    	for(j = 1; j < MAXV; j++)
            G.arcs[i][j] = INF;
        G.arcs[i][i] = 0;
        
        for(j = 0; j < MAXSITE-1; j++)
        	G.vex[i].location[j] = ' ';	G.vex[i].location[MAXSITE-1] = '\0';
        for(j = 0; j < MAXSIGHT-1; j++)
        	G.vex[i].scenery[j] = ' ';	G.vex[i].scenery[MAXSIGHT-1] = '\0';
        
        strcpy(G.vex[i].location, "暂无");
        strcpy(G.vex[i].scenery, "未录入信息");
	}
	
    /* 初始化景点名称和景点介绍  */
    strcpy(G.vex[1].location, "南门");				strcpy(G.vex[1].scenery, "作为学校的主要出入口之一,南门是本校的象征之一,展现着学校的精神风貌!");
    strcpy(G.vex[2].location, "第一教学楼");		strcpy(G.vex[2].scenery, "坐落在校园中心的第一教学楼是学生们上课、学习的重要场所,设有多个教室和多媒体教室,方便师生进行各类教学活动!");
	strcpy(G.vex[3].location, "第二教学楼");		strcpy(G.vex[3].scenery, "紧邻第一教学楼的第二教学楼也是学校重要的教学楼之一,设施齐备,提供优质的学习环境!");
	strcpy(G.vex[4].location, "第一食堂");			strcpy(G.vex[4].scenery, "位于校园内,第一食堂提供丰富的菜品选择,满足广大师生的饮食需求!");
	strcpy(G.vex[5].location, "图书馆");			strcpy(G.vex[5].scenery, "本校的图书馆是一个宽敞明亮的学习场所,拥有丰富的中外文图书和电子资源,为学生提供良好的阅读和研究环境!");
	strcpy(G.vex[6].location, "实验楼");			strcpy(G.vex[6].scenery, "该楼设有多个实验室,供学生进行科研及实践活动,为学生提供了实践技能培养的平台!");
	strcpy(G.vex[7].location, "教学科研楼");		strcpy(G.vex[7].scenery, "该楼是进行各种理论和实践教学的主要场所,它配备了现代化的实验设备和教学工具,为学生提供了良好的学术交流平台!");
	strcpy(G.vex[8].location, "东门");				strcpy(G.vex[8].scenery, "东门是学校的另一个出入口,沿着东门可通往校外的交通枢纽,提供方便的交通接驳条件!");
	strcpy(G.vex[9].location, "静苑");				strcpy(G.vex[9].scenery, "静苑是学校内一片风景优美的院落,花草绿树环绕,是学生休闲放松的好去处!");
	strcpy(G.vex[10].location, "雅苑");			strcpy(G.vex[10].scenery, "雅苑是学校的一片安静区域,有宽敞的草坪和凉亭,供学生们休息和娱乐!");
	strcpy(G.vex[11].location, "西操场");			strcpy(G.vex[11].scenery, "西操场是学校体育活动的主要场所,包括篮球、足球等运动设施,为学生提供了锻炼身体和丰富课余生活的机会!");
	strcpy(G.vex[12].location, "第二餐厅");		strcpy(G.vex[12].scenery, "位于校园内,第二餐厅提供多种美食选择,满足师生的饮食需求!");
	strcpy(G.vex[13].location, "西门");			strcpy(G.vex[13].scenery, "西门是学校的另一个出入口,沿着西门可通往周边商圈和居民区!");
	strcpy(G.vex[14].location, "北门");			strcpy(G.vex[14].scenery, "位于校园北侧的北门是学校的出入口之一,连接校园与周边社区!");
	strcpy(G.vex[15].location, "怡苑");			strcpy(G.vex[15].scenery, "怡苑是学校内一处景色宜人的院落,有花坛和绿化带,给人以宁静和愉悦的感觉!");
	strcpy(G.vex[16].location, "第三餐厅");		strcpy(G.vex[16].scenery, "第三餐厅提供多个餐厅区域,供师生就餐,菜品种类齐全,满足不同口味的需求!");
	strcpy(G.vex[17].location, "菜鸟驿站");		strcpy(G.vex[17].scenery, "学校设有菜鸟驿站,方便学生代收快递和便捷寄送包裹!");
	strcpy(G.vex[18].location, "东操");			strcpy(G.vex[18].scenery, "东操是学校体育活动的重要场所,设有运动场地和健身器材,为学生提供了锻炼身体和娱乐放松的场所!");
	strcpy(G.vex[19].location, "体育馆");			strcpy(G.vex[19].scenery, "学校的体育馆是举办大型体育赛事和文艺演出的场所,设施齐备,可容纳大量观众!");
	
    G.arcs[1][2]= G.arcs[2][1] = 338;		/* 根据大概估算设置的两点距离 */ 
    G.arcs[1][3]=G.arcs[3][1]=338;
	G.arcs[1][5]=G.arcs[5][1]=452;
	G.arcs[2][4]=G.arcs[4][2]=110;
	G.arcs[2][5]=G.arcs[5][2]=200;
	G.arcs[3][5]=G.arcs[5][3]=200;
	G.arcs[3][6]=G.arcs[6][3]=80;
	G.arcs[4][5]=G.arcs[5][4]=225;
	G.arcs[4][9]=G.arcs[9][4]=55;
	G.arcs[5][6]=G.arcs[6][5]=225;
	G.arcs[5][7]=G.arcs[7][5]=175;
	G.arcs[5][9]=G.arcs[9][5]=250;
	G.arcs[5][12]=G.arcs[12][5]=375;
	G.arcs[5][16]=G.arcs[16][5]=450;
	G.arcs[6][7]=G.arcs[7][6]=120;
	G.arcs[6][8]=G.arcs[8][6]=160;
	G.arcs[7][8]=G.arcs[8][7]=325;
	G.arcs[7][16]=G.arcs[16][7]=338;
	G.arcs[8][16]=G.arcs[16][8]=447;
	G.arcs[8][18]=G.arcs[18][8]=287;
	G.arcs[9][10]=G.arcs[10][9]=55;
	G.arcs[9][12]=G.arcs[12][9]=175;
	G.arcs[10][11]=G.arcs[11][10]=30;
	G.arcs[10][12]=G.arcs[12][10]=230;
	G.arcs[11][12]=G.arcs[12][11]=140;
	G.arcs[11][14]=G.arcs[14][11]=210;
	G.arcs[12][14]=G.arcs[14][12]=350;
	G.arcs[12][15]=G.arcs[15][12]=160;
	G.arcs[12][16]=G.arcs[16][12]=250;
	G.arcs[13][14]=G.arcs[14][13]=210;
	G.arcs[14][15]=G.arcs[15][14]=338;
	G.arcs[15][16]=G.arcs[16][15]=150;
	G.arcs[15][17]=G.arcs[17][15]=20;
	G.arcs[15][19]=G.arcs[19][15]=395;
	G.arcs[16][18]=G.arcs[18][16]=120;
	G.arcs[16][19]=G.arcs[19][16]=225;
	G.arcs[18][19]=G.arcs[19][18]=50;
}

void loadMGraph(MGraph &G, const char* file)
{
	FILE* fp;
	int i;
	if( (fp = fopen(file, "r")) == NULL ){
		printf("no mgraph!\n");
		G.vexnum = 0;
		return ;
	}
	/* 把文件中的信息全部都读到 G 中 */
	fread(&G, sizeof(G), 1, fp);
	fclose(fp);
}
void Map() {
	cout << '\n';
	cout << "\t\t   ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n";
	cout << "\t\t   ┃\t\t院校高效学校大学 zhxx校区 导航图\t      ┃\n";
	cout << "\t\t   ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛\n";
	cout << "\t\t              o14北门\n";
	cout << "\t\t              ┃                  o17菜鸟驿站\n";
	cout << "\t\t      13西门  ┃          15怡苑  ┃                     19体育馆\n";
	cout << "\t\t        o━━━━━┛━━━━━━━━━━━━━━━o━━┗━━━━━━━━━━━━━━━━━━━┏━━o\n";
	cout << "\t\t          ┃                   ┃                      ┃\n";
	cout << "\t\t          ┃         12二餐    ┃     16三餐           ┃ 18东操\n";
	cout << "\t\t          o 11西操      o━━━━━┗━━━━━━━━o━━━━━━━━━━━━━o\n";
	cout << "\t\t          ┗━━━━━━━━━━━━━┛                            ┃\n";
	cout << "\t\t          ┃             ┃                            ┃\n";
	cout << "\t\t          ┃ 10雅苑      ┃            7科研楼         ┃\n";
	cout << "\t\t          o             ┗━┓           o━━━┓━━━━━━━━━━o8东门\n";
	cout << "\t\t          ┃ 9静苑         ┃ 5图书馆   ┃   ┃\n";
	cout << "\t\t          ┗o━━━━━━━━━━━━━━o━━━━━━━━━━━┛   ┃\n";
	cout << "\t\t           ┃ 4一餐        ┃               ┃\n";
	cout << "\t\t           ┗o━━━━━━━━━━━━━┃━━━━━━━━━━━━┏━━o6实验楼\n";
	cout << "\t\t            ┃    2教一    ┃      3教二 ┃\n";
	cout << "\t\t            ┗━━━━o━━━━━━━━┓━━━━━━━━━━o━┛\n";
	cout << "\t\t                          ┃\n";
	cout << "\t\t                          ┃\n";
	cout << "\t\t  ┗━━━━━━━━━━━━━━━━━━━━ 1南门 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓\n\n";
	if(origin)
		cout << " \t\t\t    ■ ■ ■ ■ 景点数量改动注意地图未更新 ■ ■ ■ ■" << endl;
}
void Info(MGraph &G) {
	int n;
	cout<<"请输入需要查询的景点编号(1~" << G.vexnum << "):"; 
	cin>>n;
	if(0 < n && n <= G.vexnum)
		cout << G.vex[n].no << ": " << G.vex[n].location << " 地方介绍 " << G.vex[n].scenery << "\n";
	else
		cout << "哦买噶,景点编号不存在哦!\n";      
	cout << "\n请输入0返回主菜单:";
}
void Dispathall(MGraph g,int dist[],int path[],int S[],int v)	//输出从顶点v出发的所有最短路径
{	int i,j,k;
	int apath[MAXV],d;						//存放一条最短路径(逆向)及其顶点个数
	for (i=1;i<=g.vexnum;i++)				//循环输出从顶点v到i的路径
		if (S[i]==1 && i!=v)
		{	
			cout << "从" << g.vex[v].location << "到" << g.vex[i].location << "路径为: \n";
			d=0; apath[d]=i;				//添加路径上的终点
			k=path[i];
			if (k==-1)						//没有路径的情况
				cout << "无路径\n";
			else							//存在路径时输出该路径
			{	
				while (k!=v){
					d++; apath[d]=k;
					k=path[k];
				}
				d++; apath[d]=v;			//添加路径上的起点
				cout << "   " << g.vex[apath[d]].location;  // 先输出 起点 
				for (j=d-1;j>=0;j--)		//再输出其他顶点
					cout  << " -> " << g.vex[apath[j]].location;
				cout << "\n距离为: " << dist[i] << "m  所需时间为: " << int(dist[i] / speed)  << "min" << endl;
			}
		}
}
void Dispath(MGraph g,int dist[],int path[],int S[],int start, int end)
{
	
	int i, j, k;
	int apath[MAXV],d;					// 存放一条最短路径(逆向)及其顶点个数
	i = j = end; k = 0;
	if(start == end){					// 起点与终点重合 
		cout << "目的地在原地!" << endl;
		return ;
	}
	while(start != i){
		j = path[i];
		if(path[i] == -1){
			k = 0;
			break;
		}
		apath[++k] = j;
		i = j;	
	}
	if(k){
		for(i = k; i >= 1; i--)
			cout << g.vex[apath[i]].location << " -> ";
		cout << g.vex[end].location;
		cout << "\n距离为: " << dist[end] << "m  所需时间为: " << int(dist[end] / speed)  << "min" << endl;
	}else
		cout << g.vex[start].location << "!!!不可到达!!!" << g.vex[end].location;
}
void Dijkstra(MGraph g, int v, int selectno)	// Dijkstra算法
{	
	int dist[MAXV],path[MAXV];
	int S[MAXV];				// S[i]=1表示顶点i在S中, S[i]=0表示顶点i在U中
	int Mindis,i,j,u;
	for (i=1;i<=g.vexnum;i++){
		dist[i]=g.arcs[v][i];	//距离初始化
		S[i]=0;					//S[]置空
		if (g.arcs[v][i]<INF)	//路径初始化
			path[i]=v;			//顶点v到顶点i有边时,置顶点i的前一个顶点为v
		else
			path[i]=-1;			//顶点v到顶点i没边时,置顶点i的前一个顶点为-1
	}
	S[v]=1;path[v]=0;			//源点编号v放入S中
	for (i=1;i<=g.vexnum-1;i++)	//循环直到所有顶点的最短路径都求出
	{	Mindis=INF;				//Mindis置最大长度初值
		for (j=1;j<=g.vexnum;j++)		//选取不在S中(即U中)且具有最小最短路径长度的顶点u
			if (S[j]==0 && dist[j]<Mindis){
				u=j;
				Mindis=dist[j];
			}
		S[u]=1;					//顶点u加入S中
		for (j=1;j<=g.vexnum;j++)		//修改不在S中(即U中)的顶点的最短路径
			if (S[j]==0)
				if (g.arcs[u][j]<INF && dist[u]+g.arcs[u][j]<dist[j]){
					dist[j]=dist[u]+g.arcs[u][j];
					path[j]=u;
				}
	}
	if(selectno)	// 输出起始景点可到目的地景点的最短路径
	{
		cout << "从 " << g.vex[v].location << " 出发到 " << g.vex[selectno].location << " 最短路径为\n";
		Dispath(g, dist, path, S, v, selectno); 
	}else{
		cout << "最短路径为:";
		Dispathall(g, dist, path, S, v);	// 输出该景点可达其余每个景点的最短路径
	}	
}

void dispTourMenu()
{
    cout << "\n\n";
    cout << "\t         ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ 欢迎使用院校高效学校大学导航图系统 ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆\n";
    cout << "\t                                  0. 退出\n";
    cout << "\t                                  1. 查询起点到终点路径\n";
    cout << "\t                                  2. 该点可到其余各点的信息\n";
    cout << "\t                                  3. 地点信息简介\n";
    cout << "\t                                  4. 查看地图\n";
    cout << "请输入您的选择:";
}
void touristMenu(MGraph &G)
{
    int choice; 
	int start, end;
	while(true){
		dispTourMenu();
	    cin >> choice;
	    switch (choice) {
	    	case 0:
	            return ;
	        case 1:				// 在这里执行查询地点路径的功能
	            cout << "请输入 起始 景点编号:";
	            cin >> start;
	            cout << "请输入 终点 景点编号:";
	            cin >> end;
	            if(start >= 1 && start <= G.vexnum && end >= 1 && end <= G.vexnum) {
	                Dijkstra( G,start, end);
	                cout << endl;
	            }else
	                cout << "  ▲ ▲ ▲ ▲ !无效的景点编号!请确保输入的编号在 1 到" << G.vexnum << " 之间! ▲ ▲ ▲ ▲\n";
	            break;
	        case 2:				// 从起点开始到其余点的 
	            cout << "请输入起始景点编号:";
	            cin >> start;
	            if(start >= 1 && start <= G.vexnum) {
	                Dijkstra( G,start, 0);
	                cout << endl;
	            }else
	                cout << "  ▲ ▲ ▲ ▲ !无效的景点编号!请确保输入的编号在 1 到" << G.vexnum << " 之间! ▲ ▲ ▲ ▲\n";
	            break;
	        case 3:
	            Info(G);						// 在这里执行地点信息简介的功能
	            break;
			case 4:	Map(); break; 			// 查看地图 
	        default:
	            cout << "\t\t\t\t      ▲ ▲ ▲ ▲ 无效选择  ▲ ▲ ▲ ▲\n"; 
	            break; 
    	}	
	}
}

void ChangePassword() {									//能够保存密码的函数
    char oldPass[20], newPass[20];
    while(true){
    	cout << "请输入原密码 >>  ";
	    cin >> oldPass;
	    if (strcmp(oldPass, adminPassword) == 0) {
	        cout << "请输入新密码(至少5位数)>>  ";
	        cin >> newPass;
	        if(strlen(newPass)>=5){	 
		        strcpy(adminPassword, newPass);
		        cout << "密码更改成功!\n";
		        ofstream passwordFile("password.txt");		// 将新密码保存到文件
		        passwordFile << adminPassword;
		        passwordFile.close();
		        break;
			}else
				cout << "\t\t\t      !!!新密码长的至少5位数,更改失败!!!\n";
	    }else {
	    	if(!(oldPass[0] - '0')) return ;
			    cout << " \t\t\t    !!!! ▲ ▲ ▲ ▲ 原密码错误  ▲ ▲ ▲ ▲ !!!!\n";
				cout << "\t\t\t\t     (●'?'●) 输入 0 退出 (●'?'●)\n"; 
	    }
	}
}

void Addscenery(MGraph &G, const char file[]){
    if (G.vexnum >= MAXV) {
        cout << "已达到景点数量上限,无法添加新的景点!\n";
        return ;
    }
    cout << "请输入新景点的名称 >>  ";
    char name[50];
    cin >> name;
	G.vexnum++;
	if(!origin) origin = true; 
    strcpy(G.vex[G.vexnum].location, name);
    G.vex[G.vexnum].no = G.vexnum;
    for (int i = 1; i <= G.vexnum; i++) {
        G.arcs[G.vexnum][i] = INF;
        G.arcs[i][G.vexnum] = INF;
    }
    strcpy(G.vex[G.vexnum].scenery, "未录入信息");
    cout <<"第 "<< G.vexnum << " 号景点添加成功!\n";
    saveMGraph(G, file);
}

void Modifylocation(MGraph &G, const char file[]) {
    int num;
    cout << "请输入要修改的景点编号:";
    cin >> num;
    if(num >= 1 && num <= G.vexnum) {
        cout << "当前景点名称为:" << G.vex[num].location << endl;
        cout << "请输入新的景点名称(若不修改输入 n):";
        char newName[20];
        cin >> newName;
        if(newName[0] == 'n')
        	cout << "景点名称未修改!\n";
        else{
        	strcpy(G.vex[num].location, newName);
        	cout << "景点名称修改成功!\n";
		}
    	cout << "请输入景点的介绍信息(若不修改输入 n) >> ";
    	char newscenery[50];
    	cin >> newscenery;
    	if(newscenery[0] == 'n')
        	cout << "景点介绍未修改!\n";
        else{
        	strcpy(G.vex[num].scenery, newscenery);
        	cout << "景点介绍修改成功!\n";
		}
    } else {
        cout << "  ▲ ▲ ▲ ▲ !无效的景点编号!请确保输入的编号在 1 到" << G.vexnum << " 之间! ▲ ▲ ▲ ▲\n";
    }
    saveMGraph(G, file);
}

void NewPath(MGraph &G, const char* file) {
    int v1, v2, dist;
    cout << "请输入起始景点的编号:";
    cin >> v1;
    cout << "请输入终点景点的编号:";
    cin >> v2;
    if(v1 >= 1 && v1 <= G.vexnum && v2 >= 1 && v2 <= G.vexnum) {
        cout << "当前两点之间的距离为:" << G.arcs[v1][v2] << endl;
        cout << "请输入新的距离:";
        cin >> dist;
        G.arcs[v1][v2] = dist;
        G.arcs[v2][v1] = dist;  // 无向图,所以两边都要设置
        cout << "路径添加成功!\n";
    } else {
        cout << "  ▲ ▲ ▲ ▲ !无效的景点编号!请确保输入的编号在 1 到" << G.vexnum << " 之间! ▲ ▲ ▲ ▲\n";
    }
    saveMGraph(G, file);
}

void dispAdminMenu()
{
    	cout << "\n\n";
        cout << "\t\t\t   ----┏------------管理员菜单------------┓-----\r\n"; 
        cout << "\t\t\t       ┃          1. 更改密码             ┃\n";
        cout << "\t\t\t       ┃          2. 添加新的景点         ┃\n";
        cout << "\t\t\t       ┃          3. 修改景点信息         ┃\n";
        cout << "\t\t\t       ┃          4. 新建景点路径         ┃\n";
        cout << "\t\t\t       ┃          0. 返回主菜单           ┃\n";
        cout << "请输入您的选择:";
}
void AdministratorMenu(MGraph &G, const char *file) {
    int choice;
    do {
    	dispAdminMenu();
        cin >> choice;
        switch(choice) {
            case 1: ChangePassword(); break;
            case 2: Addscenery(G, file); break;
            case 3: Modifylocation(G, file); break;
            case 4: NewPath(G, file); break;
            case 0: break;
            default: cout << "无效的选择,请重新输入!\n";
        }
    } while(choice != 0);
}

void dispmenu() {
    printf("\n\n");
    cout << "                     ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ 院校高效学校大学 ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆ ☆  ☆\n"; 
    cout << "                     ┃                       0:退出                         ┃\n";    
    cout << "                     ┃                     1:管理员登录                     ┃\n";
    cout << "                     ┃                      2:游客菜单                      ┃\n";
    cout << "                     ┃                     请选择: 0 ~ 2                     ┃\r\n"; 
    cout << "请输入你选的功能>>  "; 
}

void initpassd()
{
	ifstream passwordFile("password.txt");	// 在程序的初始化部分读取密码文件
    if (passwordFile.is_open()) {
        passwordFile >> adminPassword;
        passwordFile.close();
    }else 			      // 如果文件不存在或无法打开,可以设置一个默认密码
        strcpy(adminPassword, "admin");
}
bool loginAdmi(MGraph &G, const char* file)
{
	initpassd();
	char inpassd[20];
	cout << " 请输入管理密码 >>  ";
    cin >> inpassd;
    if(strcmp(inpassd, adminPassword) == 0) {
        AdministratorMenu(G, file);
    } else {
        while(1) {
            cout << "\t\t     !!!! ▲ ▲ ▲ ▲ 原密码错误 (输入 0 退出)  ▲ ▲ ▲ ▲ !!!!\n";
        	cout << " 请再次输入管理密码 >>  ";
            cin >> inpassd;
            if(strcmp(inpassd, adminPassword) == 0) {
                AdministratorMenu(G, file); break; 
            }
            if(inpassd[0] == '0')
            	break;
        }
    }
}
void menu(MGraph &G, const char* file)				// 主菜单 开始菜单 
{
    int menu_no;					// 选项号 
	while(1){
    	dispmenu(); 				// 展示主菜单选项 
    	cin >> menu_no;
        switch(menu_no) {
        	case 0:	return ;
            case 1:	loginAdmi(G, file);	// 管理员登录
                break;
            case 2:	touristMenu(G);	// 用户主菜单 
                break;
            default:
	            cout << "\t\t     !!!! ▲ ▲ ▲ ▲   无效选择 (请重新输入)   ▲ ▲ ▲ ▲ !!!!\n";
	            break;
        }
    }
}
int main() 
{
	MGraph G;
	const char* file = "mgraph.dat";
	CreateMGraph(G);		// 灵活使用
//	loadMGraph(G, file);
	menu(G, file);    
    return 0;
}
  • 11
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值