超市总营业额分析程序

#include<stdio.h>
#include<stdlib.h>

typedef struct _Goods
{
	char name[20];//商品名
	int day;//周几
	int num;//个数
	float price;//单价
}Goods,*PGoods;

int menu()
{
	int choice;
	system("cls");
	printf("1:重新输入信息\n");
	printf("2:读盘\n");
	printf("3:存盘\n");
	printf("4:汇总\n");
	printf("0:退出\n");
	printf("请输入选择:");
	scanf("%d",&choice);
	while(choice<0||choice>4)
	{
		printf("请重新输入选择:");
		scanf("%d",&choice);
	}
	return choice;
}

int New_Goods_Info(PGoods goods)
{
	int i,temp,num=0;
	for(i=0;i<7;i++)
	{
		printf("请输入周%d记录:\n",i+1);
		while(1)
		{
			printf("请输入商品名 数量 单价:");
			fflush(stdin);
			scanf("%s",goods[num].name);
			scanf("%d",&goods[num].num);
			scanf("%f",&goods[num].price);
			goods[num].day=i;
			num++;
			printf("当天记录是否输入完毕?(1/0):");
			scanf("%d",&temp);
			if(temp==1)
			{
				break;
			}
		}
	}
	return num;
}

int main()
{
	Goods goods[100];//记录商品
	int NUM=0;//记录记录数量
	int choice;
	do
	{
		choice=menu();
		switch(choice)
		{
		case 1:
			NUM=New_Goods_Info(goods);
			break;
		case 2:
			break;
		}
	}while(choice!=0);
	return 0;
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-06-13
  • 2021-05-02
  • 2022-12-23
  • 2021-10-27
  • 2021-12-05
  • 2021-08-01
  • 2022-01-15
相关资源
相似解决方案