c语言简单收银系统程序编码,我有个C语言编写的超市收银系统,请高手修改下,帮做流程图,可追加分...

我有个C语言编写的超市收银系统,请高手修改下,帮做流程图,可追加分0

#includestruct goods{ char no[8];3char name[20];  float price;  int  amount;}good;struct customer{ struct goods g;  int  n;};FILE *fp;main(){ clrscr(); display();}display(){ int i;  printf("\n\n\n\n");  printf("\t\t**************************************************\n");  printf("\t\t\tWELCOME TO MY SUPERMARKET SYSTEM\n");  printf("\t\t\t1. Insert new record\n");  printf("\t\t\t2. Seek record\n");  printf("\t\t\t3. Check out\n");  printf("\t\t\t4. show all goods infomation\n");  printf("\t\t\t5. exit\n");  printf("\t\t**************************************************\n");  printf("\t\t\tPlease input your choice(1,2,3,4,5):");  scanf("%d",&i);  menu(i);}menu(int i){ char b[8],c[1],k[1];  struct goods *g;  switch(i)  {case 1:if(insert()==1)     printf("\n\nInput succeed!\n");   else     printf("\n\nInput Fail! Try again!\n");         break;   case 2: do   {printf("\n\nInput the goods NO(<=8):");    scanf("%s",b);    seek(b);    printf("\n\nSEEK SUCCEED!\n");    printf("\nNO\t\t\tNAME\t\t\tPRICE\t\t\tAMOUNT\n");    printf("%s\t\t\t%s\t\t\t%f\t\t%d\n\n",good.no,good.name,good.price,good.amount);    printf("\n\nCONTINUE?(Y/N):");    scanf("%s",&c);   }while(strcmp(c,"Y")==0||strcmp(c,"y")==0);           break;   case 3:do          {count();    printf("\n\nCONTINUE?(Y/N):");    scanf("%s",&c);   }while(strcmp(c,"Y")==0||strcmp(c,"y")==0);          break;   case 4:show();display();break;   case 5:exit();   default:printf("\n\nYOUR CHOICE IS ERROR,PLEASE TRY AGAIN!\n");  }  printf("\npress 0 to main menu:");  scanf("%s",&k);  if(strcmp(k,"0")==0){clrscr();display();}}int insert(){int i; do {printf("\n\nPlease insert the goods info!\n");  printf("\nInput the NO(<=8,input 0 to exit):");  scanf("%s",good.no);  if(strcmp(good.no,"0")==0)break;  printf("Input the name(<=20):");  scanf("%s",good.name);  printf("Input the price:");  scanf("%f",&good.price);  printf("Input the amount:");  scanf("%d",&good.amount);  if((fp=fopen("goods.txt","ab+"))==NULL)   {printf("\n\nFILE OPEN ERROR!");exit();}  else   i=fwrite(&good,sizeof(struct goods),1,fp);  }while(1);  fclose(fp);  return i;}show(){ int i;  if((fp=fopen("goods.txt","ab+"))==NULL)  {printf("\n\nFILE OPEN ERROR!\n");exit();}  clrscr();  printf("NO\t\t\tNAME\t\t\tPRICE\t\t\tAMOUNT\n");  while(!feof(fp))  {if(fread(&good,sizeof(struct goods),1,fp)==1)   printf("%s\t\t\t%s\t\t\t%f\t\t%d\n",good.no,good.name,good.price,good.amount);  }  fclose(fp);}seek(char p[]){ int i;  if((fp=fopen("goods.txt","ab+"))==NULL)    {printf("\n\nFILE OPEN ERROR!");exit();}  else    { while(fread(&good,sizeof(struct goods),1,fp)==1)      {  if(strcmp(good.no,p)==0)break;      }      if(strcmp(good.no,p)==0)        {fclose(fp);return;}      else      {clrscr();       printf("\n\nSEEK FAIL!");       display();      }      fclose(fp);    }}count(){ char a[8];  struct goods *r,*t;  struct customer *c;  int num=0,k=1,i,j=0;  double sum=0,amount=0;  struct goods b;  c=(struct customer*)malloc(sizeof(struct customer));  do  {printf("\n\nInput the NO(press 0 to exit):");   scanf("%s",a);   if(strcmp(a,"0")==0)   break;   seek(a);   printf("Input the number:");   scanf("%d",&num);   if(good.amount

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值