Bootstrap

超市商品管理系统(c语言)


说明:
1.因为大多数部分都是我自己写的,所以有些部分可能有些繁杂了,有错误的地方请指正。
2.因为我是日语生,英语不太好,导致我的函数名就有点简单,我不建议像我这样起函数名。

在这里插入图片描述

一.结构体定义需要的基本数据

1.(商品记录)节点结构体—(ZJD)

// (商品记录)节点结构体
typedef struct ZhiJieDian
{
 char ee[5];//购入或卖出
 char bb[15];//时间
 int cc;//数量
 int dd;//价格
 struct ZhiJieDian*next;//下个(商品记录)节点地址
}ZJD;

2.(商品)节点结构体—(JD)

// (商品)节点结构体
typedef struct JieDian
{
 char ch[12];//商品名
 int aa;//保质期
 struct JieDian*next;//下个(商品)节点地址
  //(商品记录)单链表数据
 ZJD*nen_tou;//(商品记录)单链表头指针
 ZJD*nen_wei;//(商品记录)单链表尾指针
 int val2;//(商品记录)单链表长度
 }JD;

3.(商品)单链表结构体—(LB)

// (商品)单链表结构体
typedef struct LianBiao
{
 JD*tou;//(商品)单链表头指针
 JD*wei;//(商品)单链表尾指针
 int val;//(商品)单链表长度
}LB;

二.界面功能

1.输出(商品)主菜单—(hhhh)

void hhhh()
{
 printf("\n <超 市 商 品 管 理 系 统>\n (商品管理主菜单)\n"
  " ╔═════════════════════╗\n"
  " ║ 1.增加商品 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║ 2.删除指定商品 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║ 3.查找指定商品 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║ 4.修改指定商品 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║ 5.选择指定商品操作 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║ 6.退出系统 ║\n"
  " ╚═════════════════════╝\n");
}

2.输出(商品)副菜单—(hhhh1)

void hhhh1()
{
 printf("\n <超 市 商 品 管 理 系 统>\n (商品管理子菜单)\n"
  " ╔═══════════════════╗\n"
  " ║1.删除指定商品 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║2.修改指定商品 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║3.选择指定商品操作 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║4.退出系统 ║\n"
  " ╚═══════════════════╝\n");
}

3.输出(商品记录)菜单—(hhhh2)

void hhhh2()
{
 printf("\n <超 市 商 品 管 理 系 统>\n (商品记录管理菜单)\n"
  " ╔═════════════════════╗\n"
  " ║ 1.增加指定商品记录 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║ 2.删除指定商品记录 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║ 3.修改指定商品记录 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║ 4.价格排序 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║ 5.数量排序 ║\n"
  " ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
  " ║ 6.退出系统 ║\n"
  " ╚═════════════════════╝\n");
}

4.清屏后输出命令菜单和全部商品目录—(jjjj)

void jjjj(LB*aaa)
{
	system("cls");//清屏
	hhhh();//输出(商品)主菜单
	gggg(aaa);//输出全部(商品)信息
}

5.清屏后输出命令菜单和全部商品目录—(jjjj2)

void jjjj2(JD*eee)
{
 system("cls");//清屏
 hhhh2();//输出(商品记录)菜单
 llll(eee);//输出全部(商品记录)信息
}

6.清屏后判断输出主菜单还是子菜单—(kkkk)

void kkkk(LB*aaa,int bb)
{
 system("cls");//清屏
 if(bb==0)//判断输出哪个菜单
 {
  hhhh();//输出(商品)主菜单
 }
 else
 {
  hhhh1();输出(商品)副菜单
 }
 gggg(aaa);//输出全部商品信息
}

三.输出信息 功能

1.输出全部商品目录—(gggg)

void gggg(LB*aaa)
{
	if (NULL == aaa)
	{
		printf("  单链表不存在,商品输出失败!\n");
		return;
	}
	if (NULL == aaa->tou || aaa->val == 0)
	{
		printf("  单链表没有数据,商品输出失败!\n");
		return;
	}
	JD*nev_tou2 = aaa->tou;
	printf("   商品名      保质期\n");
	for (int i = 1; i <= aaa->val; i++)
	{
		printf("   %-12s ", nev_tou2->ch);
		printf("   %-12d\n", nev_tou2->aa);
		nev_tou2 = nev_tou2->next;
	}
}

2.输出该商品全部记录—(llll)

void llll(JD*eee)
{
	if (NULL == eee)
	{
		printf("  商品不存在!\n");
		return;
	}
	ZJD*nev_tou = eee->nen_tou;
	printf("   商品名         保质期\n");
	printf("    %-10s ", eee->ch);
	printf("  %-12d\n", eee->aa);
	if (NULL == eee->nen_tou || eee->val2 == 0)
	{
		printf("    商品没有记录!\n");
		return;
	}
	printf("      购入或卖出      时间           数量         价格      \n");
	for (int i = 1; i <= eee->val2; i++)
	{
		printf("     %-12s ", nev_tou->ee);
		printf("    %-11s ", nev_tou->bb);
		printf("    %-8d", nev_tou->cc);
		printf("    %f\n", nev_tou->dd);
		nev_tou = nev_tou->next;
	}
}

四.添加 功能

1.创建(商品)链表—(aaaa)

LB*aaaa()
{
 LB*aaa = (LB*)malloc(sizeof(LB));
 if(NULL==aaa)
 {
  printf(" 单链表创建失败!\n");
  return NULL;
 }
 aaa->tou = aaa->wei = NULL;
 aaa->val = 0;
 return aaa;
}

2.创建商品节点—(bbbb)

JD*bbbb(LB*aaa)
{
 char ch1[12];
 int aa1;
 JD*bbb = (JD*)malloc(sizeof(JD));//创建节点
 if(NULL==bbb)
 {
  printf(" 单链表节点创建失败!\n");
  return NULL;
 }
 printf(" 输入商品名:");
 scanf("%s",ch1);//输入商品名
 printf(" 输入商品保质期:");
 scanf("%d",&aa1);//输入商品保质期


 if(aaa->tou==NULL)//判断链表是否有节点
 {
  aaa->tou = aaa->wei = bbb;
 }
 bbb->nen_tou = bbb->nen_wei = NULL;//
 bbb->val2 = 0;
 bbb->next = NULL;//
 strcpy(bbb->ch,ch1);//储存商品名
 bbb->aa = aa1;//储存商品保质期
 aaa->val++;//链表长度加1
 return bbb;//返回节点地址
}

3.创建(商品记录)节点—(bbbb2)

ZJD*bbbb2(JD*aaa)
{
 char ee[5];//购入或卖出
 char bb[15];//时间
 int cc;//数量
 int dd;//价格
 ZJD*bbb = (ZJD*)malloc(sizeof(ZJD));//创建节点
 if(NULL==bbb)
 {
  printf(" 单链表节点创建失败!\n");
  return NULL;
 }
 printf(" 输入购入或卖出:");
 scanf("%s",ee);//输入购入或卖出
 printf(" 输入时间:");
 scanf("%s",bb);//输入时间
 printf(" 输入数量:");
 scanf("%d",&cc);//输入数量
 printf(" 输入价格:");
 scanf("%d",&dd);//输入价格
 if(aaa->nen_tou==NULL)//判断链表是否有节点
 {
  aaa->nen_tou = aaa->nen_wei = bbb;
 }
 bbb->next = NULL;//
 strcpy(bbb->ee,ee);//储存
 strcpy(bbb->bb,bb);//储存
 bbb->cc = cc;//储存
 bbb->dd = dd;//储存
 aaa->val2++;//链表长度加1
 return bbb;//返回节点地址
}

4.添加指定商品—(cccc)

void cccc(LB*aaa)
{
 jjjj(aaa);
 int val1;
 if(NULL==aaa)
 {
  jjjj(aaa);
  printf(" 单链表不存在,商品增加失败!\n");
  return;
 }
 printf(" 输入位置:");
 scanf("%d",&val1);//输入添加的商品位置
 if(val1<=0||val1>aaa->val+1)
 {
  jjjj(aaa);
  printf(" 商品增加位置错误!\n");
  return;
 }
 if(val1==1)//头部添加
 {
  JD*nev = bbbb(aaa);
  nev->next = aaa->tou;
  aaa->tou = nev;
 }
 else if(val1==aaa->val+1)//尾部添加
 {
  aaa->wei = aaa->wei->next = bbbb(aaa);
 }
 else
  //中间添加
 {
  JD*nev = bbbb(aaa);
  JD*nev_tou = aaa->tou;
  for(int i = 1;i<val1-1;i++)
  {
   nev_tou = nev_tou->next;
  }
  nev->next = nev_tou->next;
  nev_tou->next = nev;
 }
 jjjj(aaa);//更新
}

5.添加指定商品记录—(cccc2)

void cccc2(JD*eee)
{
 jjjj2(eee);
 int val1;
 if(NULL==eee)
 {
  jjjj2(eee);
  printf(" 商品不存在!\n");
  return;
 }
 printf(" 输入位置:");
 scanf("%d",&val1);//输入添加的商品位置
 if(val1<=0||val1>eee->val2+1)
 {
  jjjj2(eee);
  printf(" 商品记录增加位置错误!\n");
  return;
 }
 if(val1==1)//头部添加
 {
  ZJD*nev = bbbb2(eee);
  nev->next = eee->nen_tou;
  eee->nen_tou = nev;
 }
 else if(val1==eee->val2+1)//尾部添加
 {
  eee->nen_wei = eee->nen_wei->next = bbbb2(eee);
 }
 else
  //中间添加
 {
  ZJD*nev = bbbb2(eee);
  ZJD*nev_tou = eee->nen_tou;
  for(int i = 1;i<val1-1;i++)
  {
   nev_tou = nev_tou->next;
  }
  nev->next = nev_tou->next;
  nev_tou->next = nev;
 }
 jjjj2(eee);//更新
}

五.刪除 功能

1.删除指定商品—(dddd)

void dddd(LB*aaa,int bb)
{
 kkkk(aaa,bb);
 int val1;
 if(NULL==aaa)
 {
  printf(" 单链表不存在,数据删除失败!\n");

  return;
 }
 if(NULL==aaa->tou)
 {
  printf(" 单链表没有数据,数据删除失败!\n");
  return;
 }
 printf(" 输入删除第几行的商品:");
 scanf("%d",&val1);//输入删除的商品位置
 if(val1<=0||val1>aaa->val)
 {
  printf(" 数据删除位置错误!\n");
  return;
 }
 if(val1==1)//头部删除
 {
  JD*nev_tou = aaa->tou;
  aaa->tou = aaa->tou->next;
  free(nev_tou);
  nev_tou = NULL;
 }
 else if(val1==aaa->val)//尾部删除
 {
  JD*nev_tou = aaa->tou;
  for(int i = 1;i<aaa->val-1;i++)
  {
   nev_tou = nev_tou->next;
  }
  nev_tou->next = NULL;
  free(aaa->wei);
  aaa->wei = nev_tou;
 }
 else
  //中间删除
 {
  JD*nev_tou = aaa->tou;
  for(int i = 1;i<val1-1;i++)
  {
   nev_tou = nev_tou->next;
  }
  JD*nev = nev_tou->next->next;
  free(nev_tou->next);
  nev_tou->next = nev;
 }
 aaa->val--;
 kkkk(aaa,bb);
}

2.删除指定商品记录—(dddd2)

void dddd2(JD*eee)
{
	jjjj2(eee);
	int val1;
	char ch;
	if (NULL == eee)
	{
		printf("  商品不存在\n");
		return;
	}
	if (NULL == eee->nen_tou)
	{
		printf("  该商品没有记录,记录删除失败!\n");
		return;
	}
	printf("  输入删除第几行的商品记录:");//输入删除的商品记录位置
	while (scanf("%d", &val1) != 1)
	{
		while ((ch = getchar()) != '\n')
		{
		}
		printf("  输入错误,重新输入:");
	}
	if (val1 <= 0 || val1>eee->val2)
	{
		printf("  数据删除位置错误!\n");
		return;
	}
	if (val1 == 1)//头部删除
	{
		ZJD*nev_tou = eee->nen_tou;
		eee->nen_tou = eee->nen_tou->next;
		free(nev_tou);
		nev_tou = NULL;

	}
	else if (val1 == eee->val2)//尾部删除
	{
		ZJD*nev_tou = eee->nen_tou;
		for (int i = 1; i<eee->val2 - 1; i++)
		{
			nev_tou = nev_tou->next;
		}
		nev_tou->next = NULL;
		free(eee->nen_wei);
		eee->nen_wei = nev_tou;
	}
	else
		//中间删除
	{
		ZJD*nev_tou = eee->nen_tou ;
		for (int i = 1; i<val1 - 1; i++)
		{
			nev_tou = nev_tou->next;
		}
		ZJD*nev = nev_tou->next->next;
		free(nev_tou->next);
		nev_tou->next = nev;
	}
	eee->val2--;
	jjjj2(eee);
}

六.修改信息 功能

1.修改指定商品信息—(ffff)

void ffff(LB*aaa,int bb)
{
	kkkk(aaa, bb);
	int val1, aa1;
	char ch1[12],ch;
	if (NULL == aaa)
	{
		printf("  单链表不存在,数据更新失败!\n");
		return;
	}
	if (NULL == aaa->tou)
	{
		printf("  单链表没有数据,数据更新失败!\n");
		return;
	}
	printf("  输入要更改的商品位置:");
	while (scanf("%d", &val1) != 1)
	{
		while ((ch = getchar()) != '\n')
		{
		}
		printf("  输入错误,重新输入:");
	}
	if (val1<0 || val1>aaa->val)
	{
		printf("  位置错误!\n");
		return;
	}
	else
	{
		JD*nev_tou = aaa->tou;
		for (int i = 1; i<val1; i++)
		{
			nev_tou = nev_tou->next;
		}
		printf("  更改后的商品名:");
		scanf("%s", ch1);
		printf("  更改后的保质期:");
		scanf("%d", &aa1);
		strcpy(nev_tou->ch, ch1);
		nev_tou->aa = aa1;
	}
	kkkk(aaa, bb);
}

2.修改指定记录信息—(ffff2)

void ffff2(JD*eee)
{
	jjjj2(eee);
	int val1, cc2;
	float dd2;
	char ee2[12], bb2[12],ch;
	if (NULL == eee)
	{
		printf("  商品不存在\n");
		return;
	}
	if (NULL == eee->nen_tou)
	{
		printf("  商品没有记录,修改失败!\n");
		return;
	}
	printf("  输入要更改的商品位置:");
	while (scanf("%d", &val1) != 1)
	{
		while ((ch = getchar()) != '\n')
		{
		}
		printf("  输入错误,重新输入:");
	}
	if (val1<0 || val1>eee->val2)
	{
		printf("  位置错误!\n");
		return;
	}
	else
	{
		ZJD*nev_tou = eee->nen_tou;
		for (int i = 1; i<val1; i++)
		{
			nev_tou = nev_tou->next;
		}
		printf("  更改后为购入或卖出:");
		scanf("%s", ee2);
		printf("  更改后的时间:");
		scanf("%s", bb2);
		printf("  更改后的数量:");
		while (scanf("%d", &cc2)!=1)
		{
			while ((ch = getchar()) != '\n')
			{}
			printf("  输入错误,重新输入\n");
		}
		printf("  更改后的价格:");
		while (scanf("%f", &dd2) != 1)
		{
			while ((ch = getchar()) != '\n')
			{}
			printf("  输入错误,重新输入\n");
		}
		strcpy(nev_tou->ee, ee2);
		strcpy(nev_tou->bb, bb2);
		nev_tou->cc = cc2;
		nev_tou->dd = dd2;
	}
	jjjj2(eee);
}

七.查找指定商品—(eeee)

LB*eeee(LB*aaa)
{
	char ch1[12];
	jjjj(aaa);
	if (NULL == aaa)
	{
		printf("  单链表不存在,商品查找失败!\n");
		return NULL;
	}
	if (NULL == aaa->tou)
	{
		printf("  单链表没有商品,商品查找失败!\n");
		return NULL;
	}
	printf("  输入查找的商品名:");
	scanf("%s", ch1);//输入查找的商品名
	LB*bbb = aaaa();//创建一个查找出的商品链表
	JD*nev_tou = aaa->tou;//创建一个临时头节点
	int ab = 0;
	for (int i = 1; i <= aaa->val; i++)
	{
		if (strstr(nev_tou->ch, ch1) != NULL)/*if (strcmp(nev_tou->ch, ch1) == 0)全名查找*/
		{
			ab = 1;
			ZJD*nnn = nev_tou->nen_tou;
			JD*nev = (JD*)malloc(sizeof(JD));//创建节点
			if (bbb->tou == NULL)//判断链表是否有节点
			{
				bbb->tou = bbb->wei = nev;
			}
			else
			{
				bbb->wei = bbb->wei->next = nev;
			}
			nev->next = NULL;
			strcpy(nev->ch, nev_tou->ch);//转存商品名地址
			nev->aa = nev_tou->aa;//转存商品保质期地址
			nev->val2 = nev_tou->val2;//转存地址
			
			for (int i = 1; i <= nev->val2; i++)
			{
				ZJD*fff = (ZJD*)malloc(sizeof(ZJD));//创建商品记录节点
				if (nev_tou->nen_tou == NULL)//判断链表是否有节点
				{
					nev_tou->nen_tou = nev_tou->nen_wei = fff;
				}
				else
				{
					nev_tou->nen_wei = nev_tou->nen_wei->next = fff;
				}
				strcpy(fff->ee, nnn->ee);//转存地址
				strcpy(fff->bb, nnn->bb);//转存地址
				fff->cc = nnn->cc;//转存地址
				fff->dd = nnn->dd;//转存地址
				nnn = nnn->next;
			}
			bbb->val++;//链表长度加1
		}
		nev_tou = nev_tou->next;//移动
	}
	if (ab)//是否查找到
	{
		system("cls");
		hhhh1();
		gggg(bbb);//输出查找出的商品链表
		return bbb;
	}
	else
	{
		printf("  没找到该商品\n");
		return NULL;
	}
}

八.排序

1.价格排序—(pppp)

void pppp(JD*eee)
{
	ZJD*iui = NULL;
	for (int ii = 1; eee->val2>ii; ii++)
	{
		ZJD*nev_tou = eee->nen_tou;
		ZJD*nev = eee->nen_tou->next;
		for (int i = 1; eee->val2>i; i++)
		{
			if (nev_tou->next == nev)//nev_tou先nev后
			{
				if (nev_tou->dd<nev->dd)//比较大小
				{
					nev_tou->next = nev->next;
					nev->next = nev_tou;
					if (i < 2)//第一次从头开始
					{
						eee->nen_tou = nev;调整头部指向
						iui = nev;
					}
					else
					{
						iui->next = nev;
						iui = iui->next;
					}
				}
			}
			else//nev先nev_tou后
			{
				if (nev->dd<nev_tou->dd)//比较大小
				{
					nev->next = nev_tou->next;
					nev_tou->next = nev;
					iui->next = nev_tou;
					iui = iui->next;
				}
			}
			if (nev_tou->next != NULL && nev->next != NULL)//判断是否到尾部,没到就执行
			{
				nev_tou = nev_tou->next;
				nev = nev->next;
			}
			else if (nev_tou->next == NULL)//调整尾部指向
				eee->nen_wei = nev_tou;
			else
			{
				eee->nen_wei = nev;
			}
		}
	}
	jjjj2(eee);
}

2.数量排序—(pppp2)

void pppp2(JD*eee)
{
	ZJD*iui = NULL;
	for (int ii = 1; eee->val2>ii; ii++)
	{
		ZJD*nev_tou = eee->nen_tou;
		ZJD*nev = eee->nen_tou->next;
		for (int i = 1; eee->val2>i; i++)
		{
			if (nev_tou->next == nev)//nev_tou先nev后
			{
				if (nev_tou->cc<nev->cc)//比较大小
				{
					nev_tou->next = nev->next;
					nev->next = nev_tou;
					if (i < 2)//第一次从头开始
					{
						eee->nen_tou = nev;调整头部指向
						iui = nev;
					}
					else
					{
						iui->next = nev;
						iui = iui->next;
					}
				}
			}
			else//nev先nev_tou后
			{
				if (nev->cc<nev_tou->cc)//比较大小
				{
					nev->next = nev_tou->next;
					nev_tou->next = nev;
					iui->next = nev_tou;
					iui = iui->next;
				}
			}
			if (nev_tou->next != NULL && nev->next != NULL)//判断是否到尾部,没到就执行
			{
				nev_tou = nev_tou->next;
				nev = nev->next;
			}
			else if (nev_tou->next == NULL)//调整尾部指向
				eee->nen_wei = nev_tou;
			else
			{
				eee->nen_wei = nev;
			}
		}
	}
	jjjj2(eee);
}

九.其他功能

1.选择指定商品进行操作记录—(iiii)

JD* iiii(LB*aaa,int bb)
{
	char ch;
	system("cls");
	if (bb == 0){
		hhhh();
	}
	else
	{
		hhhh1();
	}
	gggg(aaa);
	int val1;
	if (NULL == aaa)
	{
		printf("  单链表不存在,选择商品失败!\n");
		return NULL;
	}
	if (NULL == aaa->tou)
	{
		printf("  单链表没有商品,选择商品失败!\n");
		return NULL;
	}
	printf("  输入要选择的商品位置:");
	while (scanf("%d", &val1) != 1)
	{
		while ((ch = getchar()) != '\n')
		{
		}
		printf("  输入错误,重新输入:");
	}
	if (val1<=0 || val1>aaa->val)
	{
		printf("  选择位置错误!\n");
		return NULL;
	}
	else
	{
		JD*nev_tou = aaa->tou;
		for (int i = 1; i < val1; i++)
		{
			nev_tou = nev_tou->next;
		}
		jjjj2(nev_tou);
		return nev_tou;
	}
}

2.保存信息到文件里—(rrrr)

void rrrr(LB*aaa)
{
	JD*qwq = aaa->tou;
	FILE*hh;
	char ch2[30];
	printf("  输入文件名");
	scanf("%s", ch2);
	if ((hh = fopen(ch2, "w+")) != NULL)
	{
		for (int i = 0; aaa->val > i; i++)
		{
			fputs("   商品名      保质期\n", hh);
			fprintf(hh, "   %-12s    %-12d\n", qwq->ch, qwq->aa);
			for (int ii = 0; qwq->val2 > ii;)
			{
				ZJD*qwq2 = qwq->nen_tou;
				fputs("     购入或卖出      时间           数量         价格      \n", hh);
				for (; qwq->val2 > ii; ii++)
				{
					fprintf(hh, "      %-12s     %-11s     %-8d    %f\n", qwq2->ee, qwq2->bb, qwq2->cc, qwq2->dd);
					qwq2 = qwq2->next;
				}
				qwq = qwq->next;
			}
		}
		fclose(hh);
	}
}

十.主函数

int main()
	{
		LB*link = aaaa();//创建链表
		LB*nev1 = NULL;
		JD*eee = NULL;
		char ch;
		int sele1, bb = 0,mm=1;//储存选择结果
		hhhh();
		gggg(link);
		while (mm==1)
		{
			printf("  选择:");
			while( scanf("%d", &sele1) != 1 || !(sele1 <= 6 && sele1 >= 1))
			{
				while ((ch = getchar()) != '\n')
				{
					putchar(ch);
				}
				jjjj(link);
				printf("  输入错误,重新输入\n");
				 printf("  选择:");
			}
			switch (sele1)
			{
			case 1:cccc(link);//1.增加指定商品**
				break;
			case 2:dddd(link, bb);//2.删除指定商品**
				break;
			case 3:system("cls");// 3.查找指定商品**
				nev1 = eeee(link);
				if (NULL == nev1){}
				else if (NULL == nev1->tou){}
				else
				{
					for (bb = 1,mm=0; mm==0;)
					{
						printf("  选择:");
						while (scanf("%d", &sele1) != 1 || !(sele1 <= 4 && sele1 >= 1))
						{
							while ((ch = getchar()) != '\n')
							{
								putchar(ch);
							}
							kkkk(link,bb);
							printf("  输入错误,重新输入\n");
							printf("  选择:");
						}
						switch (sele1)
						{
						case 1:dddd(nev1, bb);//1.删除指定商品**
							break;
						case 2:ffff(nev1, bb);//2.修改指定商品**
							break;
						case 3:eee=iiii(nev1,bb);//3.选择指定商品操作记录
							for (mm = 1;mm==1;)
							{
								printf("  选择:");
								while (scanf("%d", &sele1) != 1 || !(sele1 <= 6 && sele1 >= 1))
								{
									while ((ch = getchar()) != '\n')
									{
										putchar(ch);
									}
									jjjj2(eee);
									printf("  输入错误,重新输入\n");
									printf("  选择:");
								}
								switch (sele1)
								{
								case 1:cccc2(eee);//1.1.增加指定商品记录
									break;
								case 2:dddd2(eee);//2.删除指定商品记录
									break;
								case 3:ffff2(eee);//3.修改指定商品记录
									break;
								case 4:pppp(eee);//
									break;
								case 5:pppp2(eee);//
									break;
								case 6:mm = 0;//6.退出子菜单
									kkkk(nev1,bb);
									break;
								}
							}
							break;
						case 4:mm = 1;//4.退出子菜单
							free(nev1);
							nev1 = NULL;
							jjjj(link);
							break;
						}
					}
				}
				break;
			case 4:ffff(link, bb);//4.修改指定商品
				break;
			case 5:eee=iiii(link,bb);//5.选择指定商品操作
				if (NULL == eee){}
				else
				{
					for (mm=0;mm==0;)
					{
						printf("  选择:");
						while (scanf("%d", &sele1) != 1 || !(sele1 <= 6 && sele1 >= 1))
						{
							while ((ch = getchar()) != '\n')
							{
								putchar(ch);
							}
							jjjj2(eee);
							printf("  输入错误,重新输入\n");
							printf("  选择:");
						}
						switch (sele1)
						{
						case 1:cccc2(eee);//1.1.增加指定商品记录
							break;
						case 2:dddd2(eee);//2.删除指定商品记录
							break;
						case 3:ffff2(eee);//3.修改指定商品记录
							break;
						case 4:pppp(eee);//
							break;
						case 5:pppp2(eee);//
							break;
						case 6:mm = 1;//5.退出子菜单
							jjjj(link);
							break;
						}
					}
				}
				break;
			case 6:mm = 0;//6.退出系统
				rrrr(link);
				break;
			}
			bb = 0;
		}
	}

十一.代码总体

#define _CRT_SECURE_NO_WARNINGS //关闭安全周期检查
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

// 作用: 输出(商品)主菜单.
void hhhh()
{
	printf("\n    <超 市 商 品 管 理 系 统>\n       (商品管理主菜单)\n"
		"    ╔════════════════════════╗\n"
		"    ║  1.增加指定商品        ║\n"
		"    ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"    ║  2.删除指定商品        ║\n"
		"    ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"    ║  3.查找指定商品(关键词)║\n"
		"    ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"    ║  4.修改指定商品        ║\n"
		"    ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"    ║  5.选择指定商品操作    ║\n"
		"    ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"    ║  6.退出系统(并保存数据)║\n"
		"    ╚════════════════════════╝\n");

}

// 作用: 输出(商品)副菜单.
void hhhh1() 
{
	printf("\n    <超 市 商 品 管 理 系 统>\n        (商品管理子菜单)\n"
		"   ╔═══════════════════╗\n"
		"   ║1.删除指定商品     ║\n"
		"   ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"   ║2.修改指定商品     ║\n"
		"   ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"   ║3.选择指定商品操作 ║\n"
		"   ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"   ║4.退出菜单         ║\n"
		"   ╚═══════════════════╝\n");

}

// 作用: 输出(商品)主菜单.
void hhhh2()
{
	printf("\n    <超 市 商 品 管 理 系 统>\n       (商品记录管理菜单)\n"
		"    ╔═════════════════════╗\n"
		"    ║  1.增加指定商品记录 ║\n"
		"    ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"    ║  2.删除指定商品记录 ║\n"
		"    ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"    ║  3.修改指定商品记录 ║\n"
		"    ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"    ║  4.价格排序         ║\n"
		"    ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"    ║  5.数量排序         ║\n"
		"    ║┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄║\n"
		"    ║  6.退出菜单         ║\n"
		"    ╚═════════════════════╝\n");

}

// (商品记录)节点结构体
typedef struct ZhiJieDian 
{
	char ee[5];//购入或卖出
	char bb[15];//时间
	int cc;//数量
	float dd;//价格
	struct ZhiJieDian*next;//下个节点地址
}ZJD;

// (商品)节点结构体
typedef struct JieDian
{
	char ch[12];//商品名
	int aa;//保质期
	ZJD*nen_tou;//记录头节点
	ZJD*nen_wei;//记录尾节点
	int val2;//记录链表长度
	struct JieDian*next;//下个节点地址
}JD;

// (商品)单链表结构体
typedef struct LianBiao
{
	JD*tou;//商品头节点
	JD*wei;//商品尾节点
	int val;//商品链表长度
}LB;

void gggg(LB*aaa);
void llll(JD*eee);
void jjjj(LB*aaa);

// 作用: 创建(商品)链表.
LB*aaaa()
{

	LB*aaa = (LB*)malloc(sizeof(LB));
	if (NULL == aaa)
	{
		printf("  单链表创建失败!\n");
		return NULL;
	}
	aaa->tou = aaa->wei = NULL;
	aaa->val = 0;
	return aaa;
}

// 作用: 创建商品节点.
JD*bbbb(LB*aaa)
{
	char ch1[12],ch;
	int aa1;
	JD*bbb = (JD*)malloc(sizeof(JD));//创建节点
	if (NULL == bbb)
	{
		printf("  单链表节点创建失败!\n");
		return NULL;
	}
	printf("  输入商品名:");
	scanf("%s", ch1);//输入商品名
	printf("  输入商品保质期(月):");
	while (scanf("%d", &aa1) != 1)//输入商品保质期
	{
		while ((ch = getchar()) != '\n')
		{}
		printf("  输入错误,重新输入:");
	}
	if (aaa->tou == NULL)//判断链表是否有节点
	{
		aaa->tou = aaa->wei = bbb;
	}
	bbb->nen_tou = bbb->nen_wei=NULL;//
	bbb->val2 = 0;
	bbb->next = NULL;//
	strcpy(bbb->ch, ch1);//储存商品名
	bbb->aa = aa1;//储存商品保质期
	aaa->val++;//链表长度加1
	return bbb;//返回节点地址
}

// 作用: 创建(商品记录)节点.
ZJD*bbbb2(JD*aaa)
{
	char ee[5], ch;//购入或卖出
	char bb[15];//时间
	int cc;//数量
	float dd;//价格
	ZJD*bbb = (ZJD*)malloc(sizeof(ZJD));//创建节点
	if (NULL == bbb)
	{
		printf("  单链表节点创建失败!\n");
		return NULL;
	}
	printf("  输入购入或卖出:");
	scanf("%s", ee);//输入购入或卖出
	printf("  输入时间:");
	scanf("%s", bb);//输入时间
	printf("  输入数量:");
	while (scanf("%d", &cc) != 1)//输入数量
	{
		while ((ch = getchar()) != '\n')
		{}
		printf("  输入错误,重新输入:");
	}
	printf("  输入价格:");
	while (scanf("%f", &dd) != 1)//输入价格
	{
		while ((ch = getchar()) != '\n')
		{}
		printf("  输入错误,重新输入:");
	}
	if (aaa->nen_tou== NULL)//判断链表是否有节点
	{
		aaa->nen_tou = aaa->nen_wei = bbb;
	}
	bbb->next = NULL;//
	strcpy(bbb->ee, ee);//储存
	strcpy(bbb->bb, bb);//储存
	bbb->cc = cc;//储存
	bbb->dd = dd;//储存
	aaa->val2++;//链表长度加1
	return bbb;//返回节点地址
}

// 作用: 清屏后输出命令菜单和全部商品目录.
void jjjj(LB*aaa)
{
	system("cls");
	hhhh();
	gggg(aaa);
}

// 作用: 清屏后输出命令菜单和全部商品目录.
void jjjj2(JD*eee)
{
	system("cls");
	hhhh2();
	llll(eee);
}

// 作用: 清屏后判断输出主菜单还是子菜单.
void kkkk(LB*aaa,int bb)
{
	system("cls");
	if (bb == 0){
		hhhh();
	}
	else
	{
		hhhh1();
	}
	gggg(aaa);
}

// 作用: 添加指定商品.
void cccc(LB*aaa)
{
	char ch;
	jjjj(aaa);
	int val1;
	if (NULL == aaa)
	{
		jjjj(aaa);
		printf("  单链表不存在,商品增加失败!\n");
		return;
	}
	printf("  输入位置:");//输入添加的商品位置
	while (scanf("%d", &val1) != 1)
	{
		while ((ch = getchar()) != '\n')
		{
		}
		printf("  输入错误,重新输入:");
	}
	if (val1<=0 || val1>aaa->val + 1)
	{
		jjjj(aaa);
		printf("  商品增加位置错误!\n");
		return;
	}
	if (val1 == 1)//头部添加
	{
		JD*nev = bbbb(aaa);
		nev->next = aaa->tou;
		aaa->tou = nev;
	}
	else if (val1 == aaa->val + 1)//尾部添加
	{
		aaa->wei = aaa->wei->next = bbbb(aaa);
	}
	else
		//中间添加
	{
		JD*nev = bbbb(aaa);
		JD*nev_tou = aaa->tou;
		for (int i = 1; i<val1 - 1; i++)
		{
			nev_tou = nev_tou->next;
		}
		nev->next = nev_tou->next;
		nev_tou->next = nev;
	}
	jjjj(aaa); //更新
}

// 作用: 添加指定商品记录.
void cccc2(JD*eee)
{
	jjjj2(eee);
	int val1;
	char ch;
	if (NULL == eee)
	{
		jjjj2(eee);
		printf("  商品不存在!\n");
		return;
	}
	printf("  输入位置:");
	while (scanf("%d", &val1) != 1)
	{
		while ((ch = getchar()) != '\n')
		{}
		printf("  输入错误,重新输入:");
	}
	;//输入添加的商品位置
	if (val1<=0 || val1>eee->val2 + 1)
	{
		jjjj2(eee);
		printf("  商品记录增加位置错误!\n");
		return;
	}
	if (val1 == 1)//头部添加
	{
		ZJD*nev = bbbb2(eee);
		nev->next = eee->nen_tou;
		eee->nen_tou = nev;
	}
	else if (val1 == eee->val2 + 1)//尾部添加
	{
		eee->nen_wei = eee->nen_wei->next = bbbb2(eee);
	}
	else//中间添加
	{
		ZJD*nev = bbbb2(eee);
		ZJD*nev_tou = eee->nen_tou;
		for (int i = 1; i<val1 - 1; i++)
		{
			nev_tou = nev_tou->next;
		}
		nev->next = nev_tou->next;
		nev_tou->next = nev;
	}
	jjjj2(eee); //更新
}

// 作用: 删除指定商品.
void dddd(LB*aaa,int bb)
{
	kkkk(aaa,bb);
	int val1;
	char ch;
	if (NULL == aaa)
	{
		printf("  单链表不存在,数据删除失败!\n");
		return;
	}
	if (NULL == aaa->tou)
	{
		printf("  单链表没有数据,数据删除失败!\n");
		return;
	}
	printf("  输入删除第几行的商品:");//输入删除的商品位置
	while (scanf("%d", &val1) != 1)
	{
		while ((ch = getchar()) != '\n')
		{
		}
		printf("  输入错误,重新输入:");
	}
	if (val1<=0 || val1>aaa->val)
	{
		printf("  数据删除位置错误!\n");
		return;
	}
	if (val1 == 1)//头部删除
	{
		JD*nev_tou = aaa->tou;
		aaa->tou = aaa->tou->next;
		free(nev_tou);
		nev_tou = NULL;
	}
	else if (val1 == aaa->val)//尾部删除
	{
		JD*nev_tou = aaa->tou;
		for (int i = 1; i<aaa->val - 1; i++)
		{
			nev_tou = nev_tou->next;
		}
		nev_tou->next = NULL;
		free(aaa->wei);
		aaa->wei = nev_tou;
	}
	else
		//中间删除
	{
		JD*nev_tou = aaa->tou;
		for (int i = 1; i<val1 - 1; i++)
		{
			nev_tou = nev_tou->next;
		}
		JD*nev = nev_tou->next->next;
		free(nev_tou->next);
		nev_tou->next = nev;
	}
	aaa->val--;
	kkkk(aaa, bb);
}

// 作用: 删除指定记录.
void dddd2(JD*eee)
{
	jjjj2(eee);
	int val1;
	char ch;
	if (NULL == eee)
	{
		printf("  商品不存在\n");
		return;
	}
	if (NULL == eee->nen_tou)
	{
		printf("  该商品没有记录,记录删除失败!\n");
		return;
	}
	printf("  输入删除第几行的商品:");//输入删除的商品位置
	while (scanf("%d", &val1) != 1)
	{
		while ((ch = getchar()) != '\n')
		{
		}
		printf("  输入错误,重新输入:");
	}
	if (val1 <= 0 || val1>eee->val2)
	{
		printf("  数据删除位置错误!\n");
		return;
	}
	if (val1 == 1)//头部删除
	{
		ZJD*nev_tou = eee->nen_tou;
		eee->nen_tou = eee->nen_tou->next;
		free(nev_tou);
		nev_tou = NULL;

	}
	else if (val1 == eee->val2)//尾部删除
	{
		ZJD*nev_tou = eee->nen_tou;
		for (int i = 1; i<eee->val2 - 1; i++)
		{
			nev_tou = nev_tou->next;
		}
		nev_tou->next = NULL;
		free(eee->nen_wei);
		eee->nen_wei = nev_tou;
	}
	else
		//中间删除
	{
		ZJD*nev_tou = eee->nen_tou ;
		for (int i = 1; i<val1 - 1; i++)
		{
			nev_tou = nev_tou->next;
		}
		ZJD*nev = nev_tou->next->next;
		free(nev_tou->next);
		nev_tou->next = nev;
	}
	eee->val2--;
	jjjj2(eee);
}

// 作用: 输出全部商品目录.
void gggg(LB*aaa)
{
	if (NULL == aaa)
	{
		printf("  单链表不存在,商品输出失败!\n");
		return;
	}
	if (NULL == aaa->tou || aaa->val == 0)
	{
		printf("  单链表没有数据,商品输出失败!\n");
		return;
	}
	JD*nev_tou2 = aaa->tou;
	printf("   商品名      保质期\n");
	for (int i = 1; i <= aaa->val; i++)
	{
		printf("   %-12s ", nev_tou2->ch);
		printf("   %-12d\n", nev_tou2->aa);
		nev_tou2 = nev_tou2->next;
	}
}

// 作用: 修改指定商品.
void ffff(LB*aaa,int bb)
{
	kkkk(aaa, bb);
	int val1, aa1;
	char ch1[12],ch;
	if (NULL == aaa)
	{
		printf("  单链表不存在,数据更新失败!\n");
		return;
	}
	if (NULL == aaa->tou)
	{
		printf("  单链表没有数据,数据更新失败!\n");
		return;
	}
	printf("  输入要更改的商品位置:");
	while (scanf("%d", &val1) != 1)
	{
		while ((ch = getchar()) != '\n')
		{
		}
		printf("  输入错误,重新输入:");
	}
	if (val1<0 || val1>aaa->val)
	{
		printf("  位置错误!\n");
		return;
	}
	else
	{
		JD*nev_tou = aaa->tou;
		for (int i = 1; i<val1; i++)
		{
			nev_tou = nev_tou->next;
		}
		printf("  更改后的商品名:");
		scanf("%s", ch1);
		printf("  更改后的保质期:");
		scanf("%d", &aa1);
		strcpy(nev_tou->ch, ch1);
		nev_tou->aa = aa1;
	}
	kkkk(aaa, bb);
}

// 作用: 修改指定记录.
void ffff2(JD*eee)
{
	jjjj2(eee);
	int val1, cc2;
	float dd2;
	char ee2[12], bb2[12],ch;
	if (NULL == eee)
	{
		printf("  商品不存在\n");
		return;
	}
	if (NULL == eee->nen_tou)
	{
		printf("  商品没有记录,修改失败!\n");
		return;
	}
	printf("  输入要更改的商品位置:");
	while (scanf("%d", &val1) != 1)
	{
		while ((ch = getchar()) != '\n')
		{
		}
		printf("  输入错误,重新输入:");
	}
	if (val1<0 || val1>eee->val2)
	{
		printf("  位置错误!\n");
		return;
	}
	else
	{
		ZJD*nev_tou = eee->nen_tou;
		for (int i = 1; i<val1; i++)
		{
			nev_tou = nev_tou->next;
		}
		printf("  更改后为购入或卖出:");
		scanf("%s", ee2);
		printf("  更改后的时间:");
		scanf("%s", bb2);
		printf("  更改后的数量:");
		while (scanf("%d", &cc2)!=1)
		{
			while ((ch = getchar()) != '\n')
			{}
			printf("  输入错误,重新输入\n");
		}
		printf("  更改后的价格:");
		while (scanf("%f", &dd2) != 1)
		{
			while ((ch = getchar()) != '\n')
			{}
			printf("  输入错误,重新输入\n");
		}
		strcpy(nev_tou->ee, ee2);
		strcpy(nev_tou->bb, bb2);
		nev_tou->cc = cc2;
		nev_tou->dd = dd2;
	}
	jjjj2(eee);
}

// 作用: 查找指定商品.
LB*eeee(LB*aaa)
{
	char ch1[12];
	jjjj(aaa);
	if (NULL == aaa)
	{
		printf("  单链表不存在,商品查找失败!\n");
		return NULL;
	}
	if (NULL == aaa->tou)
	{
		printf("  单链表没有商品,商品查找失败!\n");
		return NULL;
	}
	printf("  输入查找的商品名:");
	scanf("%s", ch1);//输入查找的商品名
	LB*bbb = aaaa();//创建一个查找出的商品链表
	JD*nev_tou = aaa->tou;//创建一个临时头节点
	int ab = 0;
	for (int i = 1; i <= aaa->val; i++)
	{
		if (strstr(nev_tou->ch, ch1) != NULL)/*if (strcmp(nev_tou->ch, ch1) == 0)全名查找*/
		{
			ab = 1;
			ZJD*nnn = nev_tou->nen_tou;
			JD*nev = (JD*)malloc(sizeof(JD));//创建节点
			if (bbb->tou == NULL)//判断链表是否有节点
			{
				bbb->tou = bbb->wei = nev;
			}
			else
			{
				bbb->wei = bbb->wei->next = nev;
			}
			nev->next = NULL;
			strcpy(nev->ch, nev_tou->ch);//转存商品名地址
			nev->aa = nev_tou->aa;//转存商品保质期地址
			nev->val2 = nev_tou->val2;//转存地址
			
			for (int i = 1; i <= nev->val2; i++)
			{
				ZJD*fff = (ZJD*)malloc(sizeof(ZJD));//创建商品记录节点
				if (nev_tou->nen_tou == NULL)//判断链表是否有节点
				{
					nev_tou->nen_tou = nev_tou->nen_wei = fff;
				}
				else
				{
					nev_tou->nen_wei = nev_tou->nen_wei->next = fff;
				}
				strcpy(fff->ee, nnn->ee);//转存地址
				strcpy(fff->bb, nnn->bb);//转存地址
				fff->cc = nnn->cc;//转存地址
				fff->dd = nnn->dd;//转存地址
				nnn = nnn->next;
			}
			bbb->val++;//链表长度加1
		}
		nev_tou = nev_tou->next;//移动
	}
	if (ab)//是否查找到
	{
		system("cls");
		hhhh1();
		gggg(bbb);//输出查找出的商品链表
		return bbb;
	}
	else
	{
		printf("  没找到该商品\n");
		return NULL;
	}
}

// 作用: 输出商品操作记录
void llll(JD*eee)
{
	if (NULL == eee)
	{
		printf("  商品不存在!\n");
		return;
	}
	ZJD*nev_tou = eee->nen_tou;
	printf("   商品名         保质期\n");
	printf("    %-10s ", eee->ch);
	printf("  %-12d\n", eee->aa);
	if (NULL == eee->nen_tou || eee->val2 == 0)
	{
		printf("    商品没有记录!\n");
		return;
	}
	printf("      购入或卖出      时间           数量         价格      \n");
	for (int i = 1; i <= eee->val2; i++)
	{
		printf("     %-12s ", nev_tou->ee);
		printf("    %-11s ", nev_tou->bb);
		printf("    %-8d", nev_tou->cc);
		printf("    %f\n", nev_tou->dd);
		nev_tou = nev_tou->next;
	}
}

// 作用: 选择指定商品操作记录
JD* iiii(LB*aaa,int bb)
{
	char ch;
	system("cls");
	if (bb == 0){
		hhhh();
	}
	else
	{
		hhhh1();
	}
	gggg(aaa);
	int val1;
	if (NULL == aaa)
	{
		printf("  单链表不存在,选择商品失败!\n");
		return NULL;
	}
	if (NULL == aaa->tou)
	{
		printf("  单链表没有商品,选择商品失败!\n");
		return NULL;
	}
	printf("  输入要选择的商品位置:");
	while (scanf("%d", &val1) != 1)
	{
		while ((ch = getchar()) != '\n')
		{
		}
		printf("  输入错误,重新输入:");
	}
	if (val1<=0 || val1>aaa->val)
	{
		printf("  选择位置错误!\n");
		return NULL;
	}
	else
	{
		JD*nev_tou = aaa->tou;
		for (int i = 1; i < val1; i++)
		{
			nev_tou = nev_tou->next;
		}
		jjjj2(nev_tou);
		return nev_tou;
	}
}


void rrrr(LB*aaa)
{
	JD*qwq = aaa->tou;
	FILE*hh;
	char ch2[30];
	printf("  输入文件名");
	scanf("%s", ch2);
	if ((hh = fopen(ch2, "w+")) != NULL)
	{
		for (int i = 0; aaa->val > i; i++)
		{
			fputs("   商品名      保质期\n", hh);
			fprintf(hh, "   %-12s    %-12d\n", qwq->ch, qwq->aa);
			for (int ii = 0; qwq->val2 > ii;)
			{
				ZJD*qwq2 = qwq->nen_tou;
				fputs("     购入或卖出      时间           数量         价格      \n", hh);
				for (; qwq->val2 > ii; ii++)
				{
					fprintf(hh, "      %-12s     %-11s     %-8d    %f\n", qwq2->ee, qwq2->bb, qwq2->cc, qwq2->dd);
					qwq2 = qwq2->next;
				}
				qwq = qwq->next;
			}
		}
		fclose(hh);
	}
}

//价格排序
void pppp(JD*eee)
{
	ZJD*iui = NULL;
	for (int ii = 1; eee->val2>ii; ii++)
	{
		ZJD*nev_tou = eee->nen_tou;
		ZJD*nev = eee->nen_tou->next;
		for (int i = 1; eee->val2>i; i++)
		{
			if (nev_tou->next == nev)//nev_tou先nev后
			{
				if (nev_tou->dd<nev->dd)//比较大小
				{
					nev_tou->next = nev->next;
					nev->next = nev_tou;
					if (i < 2)//第一次从头开始
					{
						eee->nen_tou = nev;调整头部指向
						iui = nev;
					}
					else
					{
						iui->next = nev;
						iui = iui->next;
					}
				}
			}
			else//nev先nev_tou后
			{
				if (nev->dd<nev_tou->dd)//比较大小
				{
					nev->next = nev_tou->next;
					nev_tou->next = nev;
					iui->next = nev_tou;
					iui = iui->next;
				}
			}
			if (nev_tou->next != NULL && nev->next != NULL)//判断是否到尾部,没到就执行
			{
				nev_tou = nev_tou->next;
				nev = nev->next;
			}
			else if (nev_tou->next == NULL)//调整尾部指向
				eee->nen_wei = nev_tou;
			else
			{
				eee->nen_wei = nev;
			}
		}
	}
	jjjj2(eee);
}

//数量排序
void pppp2(JD*eee)
{
	ZJD*iui = NULL;
	for (int ii = 1; eee->val2>ii; ii++)
	{
		ZJD*nev_tou = eee->nen_tou;
		ZJD*nev = eee->nen_tou->next;
		for (int i = 1; eee->val2>i; i++)
		{
			if (nev_tou->next == nev)//nev_tou先nev后
			{
				if (nev_tou->cc<nev->cc)//比较大小
				{
					nev_tou->next = nev->next;
					nev->next = nev_tou;
					if (i < 2)//第一次从头开始
					{
						eee->nen_tou = nev;调整头部指向
						iui = nev;
					}
					else
					{
						iui->next = nev;
						iui = iui->next;
					}
				}
			}
			else//nev先nev_tou后
			{
				if (nev->cc<nev_tou->cc)//比较大小
				{
					nev->next = nev_tou->next;
					nev_tou->next = nev;
					iui->next = nev_tou;
					iui = iui->next;
				}
			}
			if (nev_tou->next != NULL && nev->next != NULL)//判断是否到尾部,没到就执行
			{
				nev_tou = nev_tou->next;
				nev = nev->next;
			}
			else if (nev_tou->next == NULL)//调整尾部指向
				eee->nen_wei = nev_tou;
			else
			{
				eee->nen_wei = nev;
			}
		}
	}
	jjjj2(eee);
}

int main()
	{
		LB*link = aaaa();//创建链表
		LB*nev1 = NULL;
		JD*eee = NULL;
		char ch;
		int sele1, bb = 0,mm=1;//储存选择结果
		hhhh();
		gggg(link);
		while (mm==1)
		{
			printf("  选择:");
			while( scanf("%d", &sele1) != 1 || !(sele1 <= 6 && sele1 >= 1))
			{
				while ((ch = getchar()) != '\n')
				{
					putchar(ch);
				}
				jjjj(link);
				printf("  输入错误,重新输入\n");
				 printf("  选择:");
			}
			switch (sele1)
			{
			case 1:cccc(link);//1.增加指定商品**
				break;
			case 2:dddd(link, bb);//2.删除指定商品**
				break;
			case 3:system("cls");// 3.查找指定商品**
				nev1 = eeee(link);
				if (NULL == nev1){}
				else if (NULL == nev1->tou){}
				else
				{
					for (bb = 1,mm=0; mm==0;)
					{
						printf("  选择:");
						while (scanf("%d", &sele1) != 1 || !(sele1 <= 4 && sele1 >= 1))
						{
							while ((ch = getchar()) != '\n')
							{
								putchar(ch);
							}
							kkkk(link,bb);
							printf("  输入错误,重新输入\n");
							printf("  选择:");
						}
						switch (sele1)
						{
						case 1:dddd(nev1, bb);//1.删除指定商品**
							break;
						case 2:ffff(nev1, bb);//2.修改指定商品**
							break;
						case 3:eee=iiii(nev1,bb);//3.选择指定商品操作记录
							for (mm = 1;mm==1;)
							{
								printf("  选择:");
								while (scanf("%d", &sele1) != 1 || !(sele1 <= 6 && sele1 >= 1))
								{
									while ((ch = getchar()) != '\n')
									{
										putchar(ch);
									}
									jjjj2(eee);
									printf("  输入错误,重新输入\n");
									printf("  选择:");
								}
								switch (sele1)
								{
								case 1:cccc2(eee);//1.1.增加指定商品记录
									break;
								case 2:dddd2(eee);//2.删除指定商品记录
									break;
								case 3:ffff2(eee);//3.修改指定商品记录
									break;
								case 4:pppp(eee);//
									break;
								case 5:pppp2(eee);//
									break;
								case 6:mm = 0;//6.退出子菜单
									kkkk(nev1,bb);
									break;
								}
							}
							break;
						case 4:mm = 1;//4.退出子菜单
							free(nev1);
							nev1 = NULL;
							jjjj(link);
							break;
						}
					}
				}
				break;
			case 4:ffff(link, bb);//4.修改指定商品
				break;
			case 5:eee=iiii(link,bb);//5.选择指定商品操作
				if (NULL == eee){}
				else
				{
					for (mm=0;mm==0;)
					{
						printf("  选择:");
						while (scanf("%d", &sele1) != 1 || !(sele1 <= 6 && sele1 >= 1))
						{
							while ((ch = getchar()) != '\n')
							{
								putchar(ch);
							}
							jjjj2(eee);
							printf("  输入错误,重新输入\n");
							printf("  选择:");
						}
						switch (sele1)
						{
						case 1:cccc2(eee);//1.1.增加指定商品记录
							break;
						case 2:dddd2(eee);//2.删除指定商品记录
							break;
						case 3:ffff2(eee);//3.修改指定商品记录
							break;
						case 4:pppp(eee);//
							break;
						case 5:pppp2(eee);//
							break;
						case 6:mm = 1;//5.退出子菜单
							jjjj(link);
							break;
						}
					}
				}
				break;
			case 6:mm = 0;//6.退出系统
				rrrr(link);
				break;
			}
			bb = 0;
		}
	}

	
;