㈠ c语言编写的超市管理系统
有一个小型超市,出售N(N>=10)种商品,设计并实现一个系统,完成下列功能:
1. 保存及输出。超市中的各种商品信息保存在指定文件中,可以把它们输出显示。
2. 计算并排序。计算每类商品的总价值(sum,单精度)及平均价(aver,单精度,输出一位小数),将每类商品按平均价从大到小的顺序排序打印出来。
3. 统计。统计输出库存量低于100的货号及类别。统计输出有两种以上(含两种)商品库存量低于100的商品类别。
1.2总体结构
本程序主要分为八个模块:主模块、信息输出修改模块、新建信息模块、排序模块、计算模块、统计模块1、统计模块2、打印模块。
1) 主模块:通过调用各分模块实现功能;
2) 信息输出修改模块:输出显示文件中商品信息内容,添加商品信息,删除商品信息,修改商品信息;
3) 新建商品信息模块:建立一个新结构体,为链表存信息用,并且将信息保存在指定的文件中;
4) 排序模块:把文件中顺序零乱的商品信息按单价的大小从高到低进行排序,放到链表里存储;
5) 计算模块:将所有商品的价格与库存量进行累加求和;
6) 打印模块:将商品信息按每类平均价格排序(从高到低)按顺序打印出来;
7) 统计模块1:统计库存量低于100的货名及类别;
8) 统计模块2:统计商品库存量有2种以上(含2种)低于100的商品类别。
附   录(程序清单)
#include "stdio.h"         /*输入,输出头文件*/ 
#include "stdlib.h"         /*申请空间头文件*/ 
#include "string.h"         /*对字符串加工头文件*/ 
#include "conio.h"         /*清屏头文件*/ 
FILE *fp;
int n=0;           /*定义文件指针类型*/
int i,j,a[4],m;          /*定义整数类型*/ 
float aver[4],sum[4],g[4],h;      /*定义浮点类型*/ 
char c[5]="elec";         /*定义字符数组类型*/
char d[5]="comm";         /*定义字符数组类型*/
char e[5]="food";         /*定义字符数组类型*/
char f[5]="offi";         /*定义字符数组类型*/
struct good           /*定义结构体*/
{
 int num;          /*商品编号*/
 char name[20];         /*商品名称*/
 char kind[40];         /*商品类型*/
 float price;         /*商品价格*/
 char unit[10];         /*商品单位*/
 int quantity;         /*商品数量*/
 struct good *next;        /*定义结构体指针类型*/
}*head,*p1,*p2;
struct good *createlist()                /*创建链表函数*/
{
 struct good *head1,*p1,*p2;         /*定义结构体指针类型*/
 if((fp=fopen("goods message.txt","w"))==NULL)      /*判断能否打开文件*/
 {
  printf("can not open the file");
  exit(0);                  /*结束程序*/
 }
 head1=(struct good *)malloc(sizeof(struct good));     /*申请头结点空间*/ 
 p1=head1;
 p2=head1;
 printf("*********************************************\n");
 printf("请输入信息:编号,名称,类型,价格,单位,数目\n");
 printf("            (以输入“-1”表示结束输入)\n");
 printf("*********************************************\n");
 printf("____________________\n");
 scanf("%d %s %s %f %s %d",&p1->num,p1->name,p1->kind,&p1->price,p1->unit,&p1->quantity);        /*输入商品信息*/ 
 printf("____________________\n");
 p1->next=NULL;
 fprintf(fp,"%d %s %s %f %s %d ",p1->num,p1->name,p1->kind,p1->price,p1->unit,p1->quantity);             /*将商品信息写入文件*/
 while(1)
 {
  p1=(struct good *)malloc(sizeof(struct good));           /*申请新空间*/
  printf("*********************************************\n");
  printf("请输入信息:编号,名称,类型,价格,单位,数目\n");
  printf("            (以输入“-1”表示结束输入)\n");
  printf("*********************************************\n");
  printf("____________________\n");
  scanf("%d",&p1->num);
  if(p1->num==-1)               /*申请空间结束条件*/
  {
   printf("____________________\n\n");
   fprintf(fp,"%d",-1);
   fclose(fp);
   return head1;              /*返回头指针*/
  }
  scanf("%s %s %f %s %d",p1->name,p1->kind,&p1->price,p1->unit,&p1->quantity); /*输入商品信息*/
  printf("________________\n");
  fprintf(fp,"%d %s %s %f %s %d ",p1->num,p1->name,p1->kind,p1->price,p1->unit,p1->quantity);            /*将商品信息写入文件*/
  p1->next=NULL;
  p2->next=p1;
  p2=p1;
 }
}
struct good *paixu(struct good*head2)      /*链表排序函数*/ 
{
 struct good *p6,*p7,*r,*s;       /*定义结构体指针类型*/
 for(i=0;i<=3;i++)            /*赋初值值*/ 
 {
  a[i]=0;
  sum[i]=0;
  aver[i]=0;
 }
 p6=(struct good *)malloc(sizeof(struct good));      /*申请新空间*/
 p6->next=head2;
 head2=p6;
 while(p6->next!=NULL)        /*判断循环结束条件*/
 {
  p7=p6->next;
  r=p6;
  while(p7->next!=NULL)       /*判断循环结束条件*/
  {
   if((p7->next->price)>(r->next->price))    /*判断是否调换*/
   r=p7;
   p7=p7->next;
  }
  if(p6!=r)          /*判断循环结束条件*/
  {
   s=r->next;          /*指针调换*/ 
   r->next=s->next;
   s->next=p6->next;
   p6->next=s;
  }
   p6=p6->next;
 }
 p6=head2;
 head2=head2->next;
 free(p6);           /*释放第一个无效空间*/ 
 return head2;  
}
void jisuan()
{
  p1=head;
 do
 {
  if(strcmp(p1->kind,c)==0)     /*判断是否为电器类型*/            
  {
   sum[0]=sum[0]+(p1->price)*(p1->quantity);  /*求电器总价*/
   a[0]=a[0]+p1->quantity;       /*求电器总件数*/ 
  }
  if(strcmp(p1->kind,d)==0)     /*判断是否为日用品类型*/ 
  {
   sum[1]=sum[1]+(p1->price)*(p1->quantity);  /*求日用品总价*/
   a[1]=a[1]+p1->quantity;       /*求日用品总件数*/ 
  }
  if(strcmp(p1->kind,e)==0)    /*判断是否为办公用品类型*/          
  {
   sum[2]=sum[2]+(p1->price)*(p1->quantity);  /*求办公用品总价*/
   a[2]=a[2]+p1->quantity;      /*求办公用品总件数*/ 
  }
  if(strcmp(p1->kind,f)==0)     /*判断是否为食品类型*/ 
  {
   sum[3]=sum[3]+(p1->price)*(p1->quantity);  /*求食品总价*/
   a[3]=a[3]+p1->quantity;       /*求食品总件数*/ 
  }
  p1=p1->next;
 }while (p1!=NULL);        /*遍历链表结束条件*/
 for(i=0;i<4;i++)
  aver[i]=sum[i]/a[i];       /*求每类商品平均价*/
 printf("****************************************************\n");
 printf("商品类型     \t    平均价\t       总库存量\n");
 printf("****************************************************\n");
 printf("____________________________________________________\n");
 printf("电器总价值:%0.1f\t平均价:%0.1f\t总库存量:%d\n",sum[0],aver[0],a[0]);
 printf("____________________________________________________\n");
 printf("日用品总价值:%0.1f\t平均价:%0.1f\t总库存量:%d\n",sum[1],aver[1],a[1]);
 printf("____________________________________________________\n");
 printf("食品总价值:%0.1f\t平均价:%0.1f\t总库存量:%d\n",sum[2],aver[2],a[2]);
 printf("____________________________________________________\n");
 printf("办公用品总价值:%0.1f\t平均价:%0.1f\t总库存量:%d\n",sum[3],aver[3],a[3]);
 printf("____________________________________________________\n");
}
void shuchu()           /*输出商品信息函数*/
{ 
 do
 {
  struct good *p3,*p4,*p5;      /*定义结构体指针类型*/
  int n=0,p=0,q=0,r=0;
  printf("所有商品信息:\n");
  printf("编号,名称,类型,价格,单位,数目\n");
  printf("**********************************\n"); 
  if((fp=fopen("goods message.txt","rb+"))==NULL) /*判断能否打开文件*/
  {
   printf("can not open the file");
   exit(0);          /*结束程序*/
  }
  head=(struct good *)malloc(sizeof(struct good)); /*申请头结点空间*/ 
  p3=head;
  fscanf(fp,"%d %s %s %f %s %d ",&p3->num,p3->name,p3->kind,&p3->price,p3->unit,&p3->quantity);             /*从文件中写到链表*/   
  while(1)
  {
   p4=(struct good *)malloc(sizeof(struct good));  /*申请头结点空间*/ 
   fscanf(fp,"%d ",&p4->num);
   if(p4->num!=-1)        /*判断循环结束条件*/
   {
    fscanf(fp,"%s %s %f %s %d ",p4->name,p4->kind,&p4->price,p4->unit,&p4->quantity); /*从文件中写到链表*/ 
    p4->next=NULL;
    p3->next=p4;
    p3=p4;
   }
   else
   {
    p3->next=NULL;
    break;
   }
  }
  fclose(fp);           /*关闭文件*/         
  p3=head;
  while(p3!=NULL)
  { 
   printf("   %d   %s   %s   %0.1f   %s   %d\n\n",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity); 
   printf("__________________________________\n");  
   p3=p3->next;
  }
   printf("**********************************\n"); 
   printf("//////////////////////////////////\n"); 
      while(n!=4)
  {
   p3=head;
   printf("**********************************\n"); 
   printf("1 添加商品信息\n");
   printf("2 删除某商品信息\n");
   printf("3 修改某商品信息\n");
   printf("4 返回(当你完成了对某一商品的添加、删除或者修改后请按4返回)\n");
   printf("**********************************\n");    
   scanf("%d",&n);
   if(n==1)             /*添加商品信息*/
   { 
    printf("请输入商品 编号  名称  类型  价格  单位  数目\n");
    printf("**********************************\n"); 
    p4=(struct good *)malloc(sizeof(struct good));     /*申请空间*/
    scanf("%d %s %s %f %s %d",&p4->num,p4->name,p4->kind,&p4->price,p4->unit,&p4->quantity);         /*输入商品信息*/ 
    p4->next=NULL;
    while(p3->next!=NULL)        /*判断循环结束条件*/
    {
     p3=p3->next;
    }
    p3->next=p4;
    p3=head;
    if((fp=fopen("goods message.txt","w"))==NULL)               /*判断能否打开文件*/
    {
     printf("can not open the file");
     exit(0);             /*结束程序*/
    }
    while(p3!=NULL)
    {
     fprintf(fp,"%d %s %s %f %s %d ",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity)                  /*将商品信息写入文件*/
     p3=p3->next;
    }
    fprintf(fp,"%d",-1);
    fclose(fp);          /*关闭文件*/
    printf("**********************************\n"); 
    printf("__________________________________\n");
    printf("------------请按4返回-------------\n");
    printf("__________________________________\n");
    printf("**********************************\n");     
   }
   if(n==2)            /*删除商品*/
   {
    printf("**********************************\n");  
    printf("请输入需要删除的商品编号\n");
    printf("**********************************\n"); 
    scanf("%d",&p);
    printf("**********\n"); 
    printf("1 确认删除\n2 取消删除\n");
    printf("**********\n"); 
    scanf("%d",&r);
    if(r==1)
    {
     if((head->num)==p)
     {
      head=head->next;
      free(p3);         /*释放空间*/
     }
     else
     {
      p4=head;
      p3=p4->next;
      while(p3!=NULL)          /*判断循环结束条件*/
      {
       if((p3->num)==p)
       {
        p5=p3->next;
        free(p3);       /*释放空间*/
        p4->next=p5;
        break;
       }
       p3=p3->next;
       p4=p4->next;
      }
     }
     if((fp=fopen("goods message.txt","w"))==NULL)         /*判断能否打开文件*/
     {
      printf("can not open the file");
      exit(0);         /*结束程序*/
     }
     p3=head;
     while(p3!=NULL)          /*判断循环结束条件*/
     {
      fprintf(fp,"%d %s %s %f %s %d ",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);             /*将商品信息写入文件*/
      p3=p3->next;
     }
     fprintf(fp,"%d",-1);
     fclose(fp);         /*关闭文件*/
    }
    if(r==2)
     continue;         /*继续循环*/
    printf("**********************************\n"); 
    printf("__________________________________\n");
    printf("------------请按4返回-------------\n");
    printf("__________________________________\n");
    printf("**********************************\n");    
   }
   if(n==3)           /*修改某商品信息*/
   {
    printf("请输入需要修改的商品编号\n");
    scanf("%d",&q);
    while(p3!=NULL)      /*判断循环结束条件*/
    {
     if((p3->num)==q)       /*判断是否为所需要修改的商品*/ 
     {
      printf("请输入商品单价与库存量(如果单价不变请输入原来的单价)\n");
      scanf("%f %d",&p3->price,&p3->quantity);             /*输入商品价格与库存量*/ 
     }
     p3=p3->next;
    }
    if((fp=fopen("goods message.txt","w"))==NULL)               /*判断能否打开文件*/
    {
     printf("can not open the file");
     exit(0);             /*结束程序*/
    }
    p3=head;
    while(p3!=NULL)     /*判断循环结束条件*/
    {
     fprintf(fp,"%d %s %s %f %s %d ",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);               /*将商品信息写入文件*/
     p3=p3->next;
    }
    fprintf(fp,"%d",-1);
    fclose(fp);            /*关闭文件*/
    printf("**********************************\n"); 
    printf("__________________________________\n");
    printf("------------请按4返回-------------\n");
    printf("__________________________________\n");
    printf("**********************************\n");    
   }
   if(n==4)                 /*退出*/
    break;
   }
  printf("**********\n");  
  printf("1 继续修改\n---------\n2 返回\n");
  printf("**********\n"); 
  scanf("%d",&p);
  if(p==1)
   continue;        /*继续循环*/
  if(p==2)
   break;         /*跳出循环*/
 }while(n!=2);
 fclose(fp);          /*关闭文件*/
}
void printf0(struct good *p)     /*遍历链表并打印电器类商品函数*/
{
 struct good *p3;        /*定义结构体指针类型*/
 p3=p;
 while (p3!=NULL)       /*判断遍历链表循环结束条件*/
 {
  if(strcmp(p3->kind,c)==0)   /*判断商品类型是否为电器类型*/
  {
   printf("%d\t%s\t%s\t%0.1f\t%s\t%d\n",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);                    /*输出电器类商品信息*/
   printf("________________________________________________\n");
  }
  p3=p3->next;
 }
 return;
}
void printf1(struct good *p)       /*遍历链表并打印日用品类商品函数*/
{
 struct good *p3;           /*定义结构体指针类型*/
 p3=p; 
 while (p3!=NULL)       /*判断遍历链表循环结束条件*/
 {
  if(strcmp(p3->kind,d)==0)   /*判断商品类型是否为日用品类型*/
  {
   printf("%d\t%s\t%s\t%0.1f\t%s\t%d\n",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);                     /*输出日用品类商品信息*/
   printf("________________________________________________\n");
  }
  p3=p3->next;
 }
 return;
}
void printf2(struct good *p)    /*遍历链表并打印办公用品类商品函数*/
{
 struct good *p3;        /*定义结构体指针类型*/
 p3=p;
 while (p3!=NULL)       /*判断遍历链表循环结束条件*/
 {
  if(strcmp(p3->kind,e)==0)  /*判断商品类型是否为办公用品类型*/
  {
   printf("%d\t%s\t%s\t%0.1f\t%s\t%d\n",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);                    /*输出办公用品类商品信息*/
   printf("________________________________________________\n");
  }
  p3=p3->next;
 }
 return;
}
void printf3(struct good *p)        /*遍历链表并打印食品类商品函数*/
{
 struct good *p3;          /*定义结构体指针类型*/
 p3=p;
 while (p3!=NULL)      /*判断遍历链表循环结束条件*/
 { 
  if(strcmp(p3->kind,f)==0)   /*判断商品类型是否为食品类型*/
  {
   printf("%d\t%s\t%s\t%0.1f\t%s\t%d\n",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);                   /*输出食品类商品信息*/
   printf("________________________________________________\n");
  }
  p3=p3->next;
 }
 return;
}
void shunxudayin()
{
  for(i=0;i<4;i++)
  g[i]=aver[i];        /*将平均价赋给新数组*/
 for(j=0;j<3;j++)        /*将新数组用冒泡排序法排序*/
  for(i=j+1;i<4;i++)
  {
   if(g[j]<g[i])
   {
    h=g[j];
    g[j]=g[i];
    g[i]=h;
   }
  }
 printf("\n****************************\n");
 printf("商品平均价格排序表(从高到低)\n");
 printf("****************************\n");
 printf("________________________________________________\n");
 printf("编号\t名称\t类别\t单价\t单位\t数量\n");
 printf("________________________________________________\n");
 for(j=0;j<4;j++)
  for(i=0;i<4;i++)
  {
   if (aver[i]==g[j])    /*判断每类商品平均价格的先后顺序*/
    switch(i)
    {
    case 0:
     printf0(head); /*调用遍历链表并打印电器类商品函数*/
     break;
    case 1:
     printf1(head); /*调用遍历链表并打印日用品类商品函数*/
     break;
    case 2:
     printf2(head);/*调用遍历链表并打印办公用品类商品函数*/
     break;
    case 3:
     printf3(head);  /*调用遍历链表并打印食品类商品函数*/
     break;
    }
  }
}
void tongji1()
{
 p1=head;
 printf("\n************************\n");
 printf("库存量低于100的货名及类别\n");
 printf("************************\n");
 printf("________________________\n");
 printf("商品名称\t商品类型\n");
 printf("________________________\n");
 while(p1!=NULL)       /*判断遍历链表循环结束条件*/
 {
  if(p1->quantity<100)      /*判断库存量是否小于100*/
  {
   printf("%s\t%s\n",p1->name,p1->kind); /*输出商品名称及类别*/
   printf("________________________\n");
  }
  p1=p1->next;
 }
}
void tongji2()
{
  printf("\n**********************************************\n");
 printf("商品库存量有2种以上(含2种)低于100的商品类别:\n");
 printf("**********************************************\n");
 printf("________\n");
 if((a[0]<100)&&(a[0]>=2))                              /*判断电器类库存量是否为2种以上(含2种)低于100*/
 {
  printf("电器\n");
  printf("________\n");
 }
 if((a[1]<100)&&(a[1]>=2))                              /*判断日用品类库存量是否为2种以上(含2种)低于100*/
 {
  printf("日用品\n");
  printf("________\n");
 }
 if((a[2]<100)&&(a[2]>=2))                               /*判断食品类库存量是否为2种以上(含2种)低于100*/
 {
  printf("食品\n");
  printf("________\n");
 }
 if((a[3]<100)&&(a[3]>=2))                              /*判断办公用品类库存量是否为2种以上(含2种)低于100*/
 {
  printf("办公用品\n");
  printf("________\n");
 }
}
int main(int argc, char* argv[])
{
 struct good *p1,*p2;             /*定义结构体指针类型*/ 
 while(1)
 {
  printf("***********************************************\n");
  printf("1 ----------输出查看或者修改已存信息-----------\n");
  printf("-----------------------------------------------\n");
  printf("2 -----重新输入新信息(并且删除原有信息)------\n");
  printf("-----------------------------------------------\n");
  printf("3 统计商品信息(如果您还没有查看过信息请先按1)\n"); 
  printf("-----------------------------------------------\n");
  printf("4 -------------------退出---------------------\n");
  printf("***********************************************\n");
  scanf("%d",&m);
  if(m==1)
   shuchu();         /*调用输出信息函数*/
  if(m==2)
  {
   system("cls");
   head=createlist();       /*调用建立链表函数*/ 
  }
  if(m==3)
  {
   printf("统计结果如下\n");  
   head=paixu(head);       /*调用链表排序函数*/        
   jisuan();          /*调用计算函数*/ 
   shunxudayin();        /*调用顺序打印函数*/ 
   tongji1();          /*调用统计1函数*/ 
   tongji2();          /*调用统计2函数*/ 
  }
  if(m==4)
  {
   p1=head;
   while(p1!=NULL)      /*判断遍历链表结束条件*/
   {
    p2=p1->next;
    free(p1);         /*释放空间*/
    p1=p2;
   }
   break;
  }
 }
 return 0;          /*结束程序*/
}
㈡ 求一个简单的C语言超市收银系统,最好配上流程图
说实话,网上搜的才有可能是最详细,最容易理解,最适合初学者的。
超市系统确实有难有易,你说要简单的,可以,简单到什么程度呢?要注册登陆么?要商品录入么?商品信息有哪些呢,进销存系统是不是都要包含呢?要写文件么?最大多少商品?
这些你都不说,光说做一个系统,跟网上的那些无脑需求有什么区别?
最想不通的是你还要流程图...你搜搜看网络知道里要流程图的有多少?你觉的100积分有人会费时费力的给你搞这个么?
伸手党不可耻,可耻的是不动脑子的伸手党。
㈢ c语言编程 超市售货系统
你娘白养你了!
㈣ 用c语言编写超市商品管理系统 每一步旁边希望有小小的解释 希望会的...
#include "stdio.h"  //需要的一些头文件
#include "stdlib.h"
#include "cstring"
#define COUNT 30  //声明商品的种类为30中,你也可以修改
//函数声明
void start();  //启动界面
void input();  //商品数据信息输入函数
void change(); //商品数据信息修改函数
void dele();  //给定指定商品名称,删除商品信息
void output(); //商品信息输出
void search();  //商品信息查找
struct  MarketGoods{  //存数商品信息的结构体
	char goods_id[30];  //商品编号
    char goods_name[30]; //商品名称
	double goods_price; //商品价格
	double goods_discount;//商品折扣
	int goods_amount;//商品总数目
	int goods_remain;//商品剩余数目
}goods[COUNT];
int count=0;  //全局变量,用于保存实际上有多少个商品
void main()   //主函数
{
    while(1)
	start(); 
 
}
void start()  //启动菜单
{
 int chi;
  printf("                        超市商品管理系统\n");
 printf("              ********************************************\n");
 printf("              1.商品信息的录入:\n");
 printf("              2.商品信息的修改:\n");
 printf("              3.删除某个商品信息:\n");
 printf("              4.查找商品信息:\n");
 printf("              5.退出系统:\n");
 printf("              ********************************************\n");
 printf("              输入你的选择: ");
 scanf("%d",&chi);   //根据你的选择执行相应的函数
if(chi==1) input();
 else if(chi==2) change();
 else if(chi==3) dele();
 else if(chi==4) search();
 else if(chi==5) { printf("你已经退出超市商品管理系统!\n");  exit(0);}
 else {  printf(" You Enter The Choice Is Not valid ! \n");  }
}
void input() //数据录入
{
   
   char flag[20];
   do{
   printf("请输入你的商品信息:\n"); //录入商品的信息
   printf("商品编号:");
   scanf("%s",goods[count].goods_id);
   printf("商品名字:");
   scanf("%s",goods[count].goods_name);
   printf("商品价格:");
   scanf("%lf",&goods[count].goods_price);
   printf("商品折扣:");
   scanf("%lf",&goods[count].goods_discount);
   printf("商品总数目:");
   scanf("%d",&goods[count].goods_amount);
   printf("商品剩余数目:");
   scanf("%d",&goods[count].goods_remain);
count++;   //存数的商品数加一
   printf("是否继续输入数据 y是  n否 : ");  //是否还想继续输入数据
   scanf("%s",flag);
   }while(strcmp(flag,"y")==0||strcmp(flag,"Y")==0);
   output();  //调用显示商品数据
}
void change()  //数据修改
{
     char ch[20],a[20];
	 int i;
      printf("\nyou sure want change goodsInfor y/n): "); //根据商品的id来修改数据
       scanf("%s",ch);
       if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)
    { printf("\nenter you want change goods_id:");
   scanf("%s",a);
   for(i=0;i<count;i++)
   {
    if(strcmp(goods[i].goods_id,a)==0)
    {  printf("\nyou sure want change goods name(y/n): ");
       scanf("%s",ch);
       if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)   { printf("\nname:"); scanf("%s",goods[i].goods_name);}
        printf("\nyou sure want change goods price(y/n): ");
       scanf("%s",ch);
       if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)   { printf("\nprice"); scanf("%lf",&goods[i].goods_price);}
       printf("\nyou sure want goods discount(y/n): ");
    scanf("%s",ch);
    if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)   { printf("\ndiscount"); scanf("%lf",&goods[i].goods_discount);}
    printf("\nyou sure want goods amount(y/n): ");
    scanf("%s",ch);
    if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)   { printf("\namount"); scanf("%d",&goods[i].goods_amount);}
	printf("\nyou sure want goods remain(y/n): ");
    scanf("%s",ch);
    if(strcmp(ch,"y")==0||strcmp(ch,"Y")==0)   { printf("\nremain"); scanf("%d",&goods[i].goods_remain);}
 }
    }  }
output();
}
void dele()  //数据删除
{
int i,j;
char c[20];
  printf("\nenter you want delete name :\n");  //根据商品的名称来删除数据
   printf("name:");
   scanf("%s",c);
   for(i=0;i<count;i++)
   if(strcmp(c,goods[i].goods_name)==0)  break; //找到,即跳出循环
    for(j=i;j<count-1;j++)
    goods[j]=goods[j+1];
    printf("\t\t\tyou had delete %s\n",c);
    count--;
  output();
}
void output()  //数据输出
{
   int i;
	for(i=0;i<count;i++)
	{
	 printf("%s %s %lf %lf %d %d \n",goods[i].goods_id,goods[i].goods_name,goods[i].goods_price,goods[i].goods_discount,goods[i].goods_amount,goods[i].goods_remain);
	
	}
}
void search()  //数据查找
{
int i;
char a[20],ch[10];
   printf("\nenter you want look name:"); //根据商品的名称来查找数据
   scanf("%s",a);
   for(i=0;i<count;i++)  
    if(strcmp(goods[i].goods_name,a)==0)  
		printf("%s %s %lf %lf %d %d \n",goods[i].goods_id,goods[i].goods_name,goods[i].goods_price,goods[i].goods_discount,goods[i].goods_amount,goods[i].goods_remain);
}
代码在vc++6.0测试通过  有问题可以hi我
㈤ 求C语言超市管理系统的代码
你好!
要求基本可以满足,你看看这是一个程序截图,需要就联系

㈥ C语言编写“超市结账系统” 急急急!!!
#include
<stdio.h>
#include
<fstream>
#include
<iostream>
#include
<string>
#include
<vector>
#include
<assert.h>
using
namespace
std;
//
Item
info
base
class
class
ItemInfo{
public:
ItemInfo(){}
ItemInfo(string
barcode,
string
name,
float
price)
{
this->barcode
=
barcode;
this->name
=
name;
this->price
=
price;
}
ItemInfo(string
barcode)
{
this->barcode
=
barcode;
}
void
Display()
{
cout
<<
barcode
<<"\t"<<name<<"\t"<<price<<
endl;
}
void
Input()
{
cout
<<
"输入条形码:"
<<
endl;
cin
>>
barcode;
cout
<<
"输入名称:"
<<
endl;
cin
>>
name;
cout
<<
"输入价格:"
<<
endl;
cin
>>
price;
}
void
Modify()
{
cout
<<
"输入名称:"
<<
endl;
cin
>>
name;
cout
<<
"输入价格:"
<<
endl;
cin
>>
price;
}
friend
ostream&
operator<<(ostream&
stream,
ItemInfo&
item){
stream
<<
item.barcode
<<'\t'<<
item.price
<<'\t'<<
item.name<<endl;
return
stream;
}
friend
istream&
operator>>(istream&
stream,
ItemInfo&
item){
stream
>>
item.barcode
>>
item.price
>>
item.name;
return
stream;
}
public:
string
barcode;
string
name;
float
price;
};
//
Interface
class
class
DataProvider{
public:
virtual
void
GetFullData(string
barcode,
string&
name,
float&
price)
=
0;
};
//
Purchase
item
class
class
ItemPurchaseInfo
:
public
ItemInfo{
public:
ItemPurchaseInfo():ItemInfo(){}
ItemPurchaseInfo(string
barcode,
int
count=1)
:
ItemInfo(barcode)
{
this->count
=
count;
}
//
Rember
to
call
this
when
barcode
set
void
GetFullData(DataProvider&
aPro)
{
aPro.GetFullData(barcode,
name,
price);
}
void
Input()
{
cout
<<
"输入条形码:"
<<
endl;
cin
>>
barcode;
cout
<<
"输入数量:"
<<
endl;
cin
>>
count;
}
void
Display()
{
cout
<<
barcode
<<"\t"<<name<<"\t"<<price<<"\t"<<count<<
endl;
}
public:
string
barcode;
int
count;
};
//
Item
list
class
class
ItemList
{
public:
ItemList(){items.clear();}
friend
ostream&
operator<<(ostream&
stream,
ItemList&
list){
unsigned
int
count
=
list.items.size();
stream
<<count<<endl;
for(unsigned
int
i(0);i<count;i++)
stream<<
list.items.at(i);
return
stream;
}
friend
istream&
operator>>(istream&
stream,
ItemList&
list){
unsigned
int
count(0);
stream
>>count;
list.items.clear();
for(unsigned
int
i(0);i<count;i++){
ItemInfo
item;
stream
>>
item;
list.items.insert(list.items.end(),
item);
}
return
stream;
}
void
Add(ItemInfo
item)
{
items.insert(items.end(),
item);
}
void
Modify()
{
string
barcode;
cout
<<
"输入条形码:"
<<
endl;
cin
>>
barcode;
for(unsigned
int
i(0);i<items.size();i++)
{
if(items.at(i).barcode
==
barcode
)
{
items.at(i).Modify();
}
}
}
public:
vector<ItemInfo>
items;
};
//
Purchase
item
list
class
class
PurchaseItemList
{
public:
PurchaseItemList(){items.clear();}
void
Add(ItemPurchaseInfo
item)
{items.insert(items.end(),
item);}
public:
vector<ItemPurchaseInfo>
items;
};
//
Implements
the
interface
class
class
Cashier
:
public
DataProvider
{
public:
Cashier()
:
purchase(),
stock(){}
~Cashier(){}
public:
//
User
funcs
void
CheckIn(){
purchase.items.clear();
int
opt(0);
do
{
unsigned
int
i(0);
ItemPurchaseInfo
ipi;
ipi.Input();
purchase.Add(ipi);
cout
<<
"按0退出,任意键继续"
<<
endl;
cin
>>
opt;
}
while(opt);
}
void
CheckOut(){
for(unsigned
int
i(0);
i
<
purchase.items.size();
i++)
{
purchase.items.at(i).GetFullData(
*this
);
}
float
checkin(0);
cout
<<
"输入收款数:"
<<
endl;
cin
>>
checkin;
DisplayList(checkin);
}
void
Display()
{
cout
<<
endl<<"商品清单
"<<
stock.items.size()
<<
endl;
cout
<<"--------------------------------------"
<<
endl;
for(unsigned
int
i(0);i<
stock.items.size();
i++){
stock.items.at(i).Display();
}
cout
<<"--------------------------------------"
<<
endl;
}
void
DisplayList(float
checkin)
{
cout
<<
endl<<"购物小票清单"
<<
endl;
cout
<<"--------------------------------------"
<<
endl;
float
total(0.0);
for(unsigned
int
i(0);
i
<
purchase.items.size();
i++)
{
purchase.items.at(i).Display();
total
+=
purchase.items.at(i).price
*
purchase.items.at(i).count;
}
cout
<<"--------------------------------------"
<<
endl;
cout
<<"货款合计:"<<
total
<<
"元"
<<
endl;
cout
<<"收款数:"<<
checkin
<<
"元"
<<
endl;
float
change(checkin-total);
assert(
change
>=
0.0);
cout
<<"找零:"<<
change
<<
"元"
<<
endl<<
endl;
}
friend
ostream&
operator<<(ostream&
stream,
Cashier&
c){
stream
<<
c.stock;
return
stream;
}
friend
istream&
operator>>(istream&
stream,
Cashier&
c){
c.stock.items.clear();
stream
>>
c.stock;
return
stream;
}
public:
//
interface
func
void
GetFullData(string
barcode,
string&
name,
float&price)
{
//
go
through
stock
and
find
the
item
by
barcode
matching
for(unsigned
int
i(0);
i
<
stock.items.size();
i++)
{
if(stock.items.at(i).barcode
==
barcode)
{
name
=
stock.items.at(i).name;
price
=
stock.items.at(i).price;
}
}
}
public:
PurchaseItemList
purchase;
ItemList
stock;
};
int
main()
{
int
opt(0);
Cashier
cashier;
ifstream
fin("data.bin",
ios::in
|
ios::binary);
fin.seekg(0,
ios::beg);
//cashier.stock.Load(fin);
fin
>>
cashier;
fin.close();
ofstream
fout;
ItemInfo
item;
do{
cout
<<
"1.
新购买"
<<
endl;
cout
<<
"2.
输入新商品信息"
<<
endl;
cout
<<
"3.
修改商品信息"
<<
endl;
cout
<<
"4.
显示商品信息"
<<
endl;
cout
<<
"0.
退出"
<<
endl;
cin
>>
opt;
switch(opt)
{
case
1:
cashier.CheckIn();
cashier.CheckOut();
break;
case
2:
item.Input();
cashier.stock.Add(item);
fout.open("data.bin",
ios::out|
ios::binary);
fout.seekp(0,ios::beg);
fout
<<
cashier;
fout.close();
break;
case
3:
cashier.stock.Modify();
fout.open("data.bin",
ios::out|
ios::app
|
ios::binary);
fout
<<
cashier;
fout.close();
break;
case
4:
cashier.Display();
break;
default:
break;
}
}
while(opt);
return
0;
}
㈦ c语言 超市管理系统
有一个小型超市,出售N(N>=10)种商品,设计并实现一个系统,完成下列功能:
1. 保存及输出。超市中的各种商品信息保存在指定文件中,可以把它们输出显示。
2. 计算并排序。计算每类商品的总价值(sum,单精度)及平均价(aver,单精度,输出一位小数),将每类商品按平均价从大到小的顺序排序打印出来。
3. 统计。统计输出库存量低于100的货号及类别。统计输出有两种以上(含两种)商品库存量低于100的商品类别。
1.2总体结构
本程序主要分为八个模块:主模块、信息输出修改模块、新建信息模块、排序模块、计算模块、统计模块1、统计模块2、打印模块。
1) 主模块:通过调用各分模块实现功能;
2) 信息输出修改模块:输出显示文件中商品信息内容,添加商品信息,删除商品信息,修改商品信息;
3) 新建商品信息模块:建立一个新结构体,为链表存信息用,并且将信息保存在指定的文件中;
4) 排序模块:把文件中顺序零乱的商品信息按单价的大小从高到低进行排序,放到链表里存储;
5) 计算模块:将所有商品的价格与库存量进行累加求和;
6) 打印模块:将商品信息按每类平均价格排序(从高到低)按顺序打印出来;
7) 统计模块1:统计库存量低于100的货名及类别;
8) 统计模块2:统计商品库存量有2种以上(含2种)低于100的商品类别。
附   录(程序清单)
#include "stdio.h"         /*输入,输出头文件*/ 
#include "stdlib.h"         /*申请空间头文件*/ 
#include "string.h"         /*对字符串加工头文件*/ 
#include "conio.h"         /*清屏头文件*/ 
FILE *fp;
int n=0;           /*定义文件指针类型*/
int i,j,a[4],m;          /*定义整数类型*/ 
float aver[4],sum[4],g[4],h;      /*定义浮点类型*/ 
char c[5]="elec";         /*定义字符数组类型*/
char d[5]="comm";         /*定义字符数组类型*/
char e[5]="food";         /*定义字符数组类型*/
char f[5]="offi";         /*定义字符数组类型*/
struct good           /*定义结构体*/
{
 int num;          /*商品编号*/
 char name[20];         /*商品名称*/
 char kind[40];         /*商品类型*/
 float price;         /*商品价格*/
 char unit[10];         /*商品单位*/
 int quantity;         /*商品数量*/
 struct good *next;        /*定义结构体指针类型*/
}*head,*p1,*p2;
struct good *createlist()                /*创建链表函数*/
{
 struct good *head1,*p1,*p2;         /*定义结构体指针类型*/
 if((fp=fopen("goods message.txt","w"))==NULL)      /*判断能否打开文件*/
 {
  printf("can not open the file");
  exit(0);                  /*结束程序*/
 }
 head1=(struct good *)malloc(sizeof(struct good));     /*申请头结点空间*/ 
 p1=head1;
 p2=head1;
 printf("*********************************************\n");
 printf("请输入信息:编号,名称,类型,价格,单位,数目\n");
 printf("            (以输入“-1”表示结束输入)\n");
 printf("*********************************************\n");
 printf("____________________\n");
 scanf("%d %s %s %f %s %d",&p1->num,p1->name,p1->kind,&p1->price,p1->unit,&p1->quantity);        /*输入商品信息*/ 
 printf("____________________\n");
 p1->next=NULL;
 fprintf(fp,"%d %s %s %f %s %d ",p1->num,p1->name,p1->kind,p1->price,p1->unit,p1->quantity);             /*将商品信息写入文件*/
 while(1)
 {
  p1=(struct good *)malloc(sizeof(struct good));           /*申请新空间*/
  printf("*********************************************\n");
  printf("请输入信息:编号,名称,类型,价格,单位,数目\n");
  printf("            (以输入“-1”表示结束输入)\n");
  printf("*********************************************\n");
  printf("____________________\n");
  scanf("%d",&p1->num);
  if(p1->num==-1)               /*申请空间结束条件*/
  {
   printf("____________________\n\n");
   fprintf(fp,"%d",-1);
   fclose(fp);
   return head1;              /*返回头指针*/
  }
  scanf("%s %s %f %s %d",p1->name,p1->kind,&p1->price,p1->unit,&p1->quantity); /*输入商品信息*/
  printf("________________\n");
  fprintf(fp,"%d %s %s %f %s %d ",p1->num,p1->name,p1->kind,p1->price,p1->unit,p1->quantity);            /*将商品信息写入文件*/
  p1->next=NULL;
  p2->next=p1;
  p2=p1;
 }
}
struct good *paixu(struct good*head2)      /*链表排序函数*/ 
{
 struct good *p6,*p7,*r,*s;       /*定义结构体指针类型*/
 for(i=0;i<=3;i++)            /*赋初值值*/ 
 {
  a[i]=0;
  sum[i]=0;
  aver[i]=0;
 }
 p6=(struct good *)malloc(sizeof(struct good));      /*申请新空间*/
 p6->next=head2;
 head2=p6;
 while(p6->next!=NULL)        /*判断循环结束条件*/
 {
  p7=p6->next;
  r=p6;
  while(p7->next!=NULL)       /*判断循环结束条件*/
  {
   if((p7->next->price)>(r->next->price))    /*判断是否调换*/
   r=p7;
   p7=p7->next;
  }
  if(p6!=r)          /*判断循环结束条件*/
  {
   s=r->next;          /*指针调换*/ 
   r->next=s->next;
   s->next=p6->next;
   p6->next=s;
  }
   p6=p6->next;
 }
 p6=head2;
 head2=head2->next;
 free(p6);           /*释放第一个无效空间*/ 
 return head2;  
}
void jisuan()
{
  p1=head;
 do
 {
  if(strcmp(p1->kind,c)==0)     /*判断是否为电器类型*/            
  {
   sum[0]=sum[0]+(p1->price)*(p1->quantity);  /*求电器总价*/
   a[0]=a[0]+p1->quantity;       /*求电器总件数*/ 
  }
  if(strcmp(p1->kind,d)==0)     /*判断是否为日用品类型*/ 
  {
   sum[1]=sum[1]+(p1->price)*(p1->quantity);  /*求日用品总价*/
   a[1]=a[1]+p1->quantity;       /*求日用品总件数*/ 
  }
  if(strcmp(p1->kind,e)==0)    /*判断是否为办公用品类型*/          
  {
   sum[2]=sum[2]+(p1->price)*(p1->quantity);  /*求办公用品总价*/
   a[2]=a[2]+p1->quantity;      /*求办公用品总件数*/ 
  }
  if(strcmp(p1->kind,f)==0)     /*判断是否为食品类型*/ 
  {
   sum[3]=sum[3]+(p1->price)*(p1->quantity);  /*求食品总价*/
   a[3]=a[3]+p1->quantity;       /*求食品总件数*/ 
  }
  p1=p1->next;
 }while (p1!=NULL);        /*遍历链表结束条件*/
 for(i=0;i<4;i++)
  aver[i]=sum[i]/a[i];       /*求每类商品平均价*/
 printf("****************************************************\n");
 printf("商品类型     \t    平均价\t       总库存量\n");
 printf("****************************************************\n");
 printf("____________________________________________________\n");
 printf("电器总价值:%0.1f\t平均价:%0.1f\t总库存量:%d\n",sum[0],aver[0],a[0]);
 printf("____________________________________________________\n");
 printf("日用品总价值:%0.1f\t平均价:%0.1f\t总库存量:%d\n",sum[1],aver[1],a[1]);
 printf("____________________________________________________\n");
 printf("食品总价值:%0.1f\t平均价:%0.1f\t总库存量:%d\n",sum[2],aver[2],a[2]);
 printf("____________________________________________________\n");
 printf("办公用品总价值:%0.1f\t平均价:%0.1f\t总库存量:%d\n",sum[3],aver[3],a[3]);
 printf("____________________________________________________\n");
}
void shuchu()           /*输出商品信息函数*/
{ 
 do
 {
  struct good *p3,*p4,*p5;      /*定义结构体指针类型*/
  int n=0,p=0,q=0,r=0;
  printf("所有商品信息:\n");
  printf("编号,名称,类型,价格,单位,数目\n");
  printf("**********************************\n"); 
  if((fp=fopen("goods message.txt","rb+"))==NULL) /*判断能否打开文件*/
  {
   printf("can not open the file");
   exit(0);          /*结束程序*/
  }
  head=(struct good *)malloc(sizeof(struct good)); /*申请头结点空间*/ 
  p3=head;
  fscanf(fp,"%d %s %s %f %s %d ",&p3->num,p3->name,p3->kind,&p3->price,p3->unit,&p3->quantity);             /*从文件中写到链表*/   
  while(1)
  {
   p4=(struct good *)malloc(sizeof(struct good));  /*申请头结点空间*/ 
   fscanf(fp,"%d ",&p4->num);
   if(p4->num!=-1)        /*判断循环结束条件*/
   {
    fscanf(fp,"%s %s %f %s %d ",p4->name,p4->kind,&p4->price,p4->unit,&p4->quantity); /*从文件中写到链表*/ 
    p4->next=NULL;
    p3->next=p4;
    p3=p4;
   }
   else
   {
    p3->next=NULL;
    break;
   }
  }
  fclose(fp);           /*关闭文件*/         
  p3=head;
  while(p3!=NULL)
  { 
   printf("   %d   %s   %s   %0.1f   %s   %d\n\n",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity); 
   printf("__________________________________\n");  
   p3=p3->next;
  }
   printf("**********************************\n"); 
   printf("//////////////////////////////////\n"); 
      while(n!=4)
  {
   p3=head;
   printf("**********************************\n"); 
   printf("1 添加商品信息\n");
   printf("2 删除某商品信息\n");
   printf("3 修改某商品信息\n");
   printf("4 返回(当你完成了对某一商品的添加、删除或者修改后请按4返回)\n");
   printf("**********************************\n");    
   scanf("%d",&n);
   if(n==1)             /*添加商品信息*/
   { 
    printf("请输入商品 编号  名称  类型  价格  单位  数目\n");
    printf("**********************************\n"); 
    p4=(struct good *)malloc(sizeof(struct good));     /*申请空间*/
    scanf("%d %s %s %f %s %d",&p4->num,p4->name,p4->kind,&p4->price,p4->unit,&p4->quantity);         /*输入商品信息*/ 
    p4->next=NULL;
    while(p3->next!=NULL)        /*判断循环结束条件*/
    {
     p3=p3->next;
    }
    p3->next=p4;
    p3=head;
    if((fp=fopen("goods message.txt","w"))==NULL)               /*判断能否打开文件*/
    {
     printf("can not open the file");
     exit(0);             /*结束程序*/
    }
    while(p3!=NULL)
    {
     fprintf(fp,"%d %s %s %f %s %d ",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity)                  /*将商品信息写入文件*/
     p3=p3->next;
    }
    fprintf(fp,"%d",-1);
    fclose(fp);          /*关闭文件*/
    printf("**********************************\n"); 
    printf("__________________________________\n");
    printf("------------请按4返回-------------\n");
    printf("__________________________________\n");
    printf("**********************************\n");     
   }
   if(n==2)            /*删除商品*/
   {
    printf("**********************************\n");  
    printf("请输入需要删除的商品编号\n");
    printf("**********************************\n"); 
    scanf("%d",&p);
    printf("**********\n"); 
    printf("1 确认删除\n2 取消删除\n");
    printf("**********\n"); 
    scanf("%d",&r);
    if(r==1)
    {
     if((head->num)==p)
     {
      head=head->next;
      free(p3);         /*释放空间*/
     }
     else
     {
      p4=head;
      p3=p4->next;
      while(p3!=NULL)          /*判断循环结束条件*/
      {
       if((p3->num)==p)
       {
        p5=p3->next;
        free(p3);       /*释放空间*/
        p4->next=p5;
        break;
       }
       p3=p3->next;
       p4=p4->next;
      }
     }
     if((fp=fopen("goods message.txt","w"))==NULL)         /*判断能否打开文件*/
     {
      printf("can not open the file");
      exit(0);         /*结束程序*/
     }
     p3=head;
     while(p3!=NULL)          /*判断循环结束条件*/
     {
      fprintf(fp,"%d %s %s %f %s %d ",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);             /*将商品信息写入文件*/
      p3=p3->next;
     }
     fprintf(fp,"%d",-1);
     fclose(fp);         /*关闭文件*/
    }
    if(r==2)
     continue;         /*继续循环*/
    printf("**********************************\n"); 
    printf("__________________________________\n");
    printf("------------请按4返回-------------\n");
    printf("__________________________________\n");
    printf("**********************************\n");    
   }
   if(n==3)           /*修改某商品信息*/
   {
    printf("请输入需要修改的商品编号\n");
    scanf("%d",&q);
    while(p3!=NULL)      /*判断循环结束条件*/
    {
     if((p3->num)==q)       /*判断是否为所需要修改的商品*/ 
     {
      printf("请输入商品单价与库存量(如果单价不变请输入原来的单价)\n");
      scanf("%f %d",&p3->price,&p3->quantity);             /*输入商品价格与库存量*/ 
     }
     p3=p3->next;
    }
    if((fp=fopen("goods message.txt","w"))==NULL)               /*判断能否打开文件*/
    {
     printf("can not open the file");
     exit(0);             /*结束程序*/
    }
    p3=head;
    while(p3!=NULL)     /*判断循环结束条件*/
    {
     fprintf(fp,"%d %s %s %f %s %d ",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);               /*将商品信息写入文件*/
     p3=p3->next;
    }
    fprintf(fp,"%d",-1);
    fclose(fp);            /*关闭文件*/
    printf("**********************************\n"); 
    printf("__________________________________\n");
    printf("------------请按4返回-------------\n");
    printf("__________________________________\n");
    printf("**********************************\n");    
   }
   if(n==4)                 /*退出*/
    break;
   }
  printf("**********\n");  
  printf("1 继续修改\n---------\n2 返回\n");
  printf("**********\n"); 
  scanf("%d",&p);
  if(p==1)
   continue;        /*继续循环*/
  if(p==2)
   break;         /*跳出循环*/
 }while(n!=2);
 fclose(fp);          /*关闭文件*/
}
void printf0(struct good *p)     /*遍历链表并打印电器类商品函数*/
{
 struct good *p3;        /*定义结构体指针类型*/
 p3=p;
 while (p3!=NULL)       /*判断遍历链表循环结束条件*/
 {
  if(strcmp(p3->kind,c)==0)   /*判断商品类型是否为电器类型*/
  {
   printf("%d\t%s\t%s\t%0.1f\t%s\t%d\n",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);                    /*输出电器类商品信息*/
   printf("________________________________________________\n");
  }
  p3=p3->next;
 }
 return;
}
void printf1(struct good *p)       /*遍历链表并打印日用品类商品函数*/
{
 struct good *p3;           /*定义结构体指针类型*/
 p3=p; 
 while (p3!=NULL)       /*判断遍历链表循环结束条件*/
 {
  if(strcmp(p3->kind,d)==0)   /*判断商品类型是否为日用品类型*/
  {
   printf("%d\t%s\t%s\t%0.1f\t%s\t%d\n",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);                     /*输出日用品类商品信息*/
   printf("________________________________________________\n");
  }
  p3=p3->next;
 }
 return;
}
void printf2(struct good *p)    /*遍历链表并打印办公用品类商品函数*/
{
 struct good *p3;        /*定义结构体指针类型*/
 p3=p;
 while (p3!=NULL)       /*判断遍历链表循环结束条件*/
 {
  if(strcmp(p3->kind,e)==0)  /*判断商品类型是否为办公用品类型*/
  {
   printf("%d\t%s\t%s\t%0.1f\t%s\t%d\n",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);                    /*输出办公用品类商品信息*/
   printf("________________________________________________\n");
  }
  p3=p3->next;
 }
 return;
}
void printf3(struct good *p)        /*遍历链表并打印食品类商品函数*/
{
 struct good *p3;          /*定义结构体指针类型*/
 p3=p;
 while (p3!=NULL)      /*判断遍历链表循环结束条件*/
 { 
  if(strcmp(p3->kind,f)==0)   /*判断商品类型是否为食品类型*/
  {
   printf("%d\t%s\t%s\t%0.1f\t%s\t%d\n",p3->num,p3->name,p3->kind,p3->price,p3->unit,p3->quantity);                   /*输出食品类商品信息*/
   printf("________________________________________________\n");
  }
  p3=p3->next;
 }
 return;
}
void shunxudayin()
{
  for(i=0;i<4;i++)
  g[i]=aver[i];        /*将平均价赋给新数组*/
 for(j=0;j<3;j++)        /*将新数组用冒泡排序法排序*/
  for(i=j+1;i<4;i++)
  {
   if(g[j]<g[i])
   {
    h=g[j];
    g[j]=g[i];
    g[i]=h;
   }
  }
 printf("\n****************************\n");
 printf("商品平均价格排序表(从高到低)\n");
 printf("****************************\n");
 printf("________________________________________________\n");
 printf("编号\t名称\t类别\t单价\t单位\t数量\n");
 printf("________________________________________________\n");
 for(j=0;j<4;j++)
  for(i=0;i<4;i++)
  {
   if (aver[i]==g[j])    /*判断每类商品平均价格的先后顺序*/
    switch(i)
    {
    case 0:
     printf0(head); /*调用遍历链表并打印电器类商品函数*/
     break;
    case 1:
     printf1(head); /*调用遍历链表并打印日用品类商品函数*/
     break;
    case 2:
     printf2(head);/*调用遍历链表并打印办公用品类商品函数*/
     break;
    case 3:
     printf3(head);  /*调用遍历链表并打印食品类商品函数*/
     break;
    }
  }
}
void tongji1()
{
 p1=head;
 printf("\n************************\n");
 printf("库存量低于100的货名及类别\n");
 printf("************************\n");
 printf("________________________\n");
 printf("商品名称\t商品类型\n");
 printf("________________________\n");
 while(p1!=NULL)       /*判断遍历链表循环结束条件*/
 {
  if(p1->quantity<100)      /*判断库存量是否小于100*/
  {
   printf("%s\t%s\n",p1->name,p1->kind); /*输出商品名称及类别*/
   printf("________________________\n");
  }
  p1=p1->next;
 }
}
void tongji2()
{
  printf("\n**********************************************\n");
 printf("商品库存量有2种以上(含2种)低于100的商品类别:\n");
 printf("**********************************************\n");
 printf("________\n");
 if((a[0]<100)&&(a[0]>=2))                              /*判断电器类库存量是否为2种以上(含2种)低于100*/
 {
  printf("电器\n");
  printf("________\n");
 }
 if((a[1]<100)&&(a[1]>=2))                              /*判断日用品类库存量是否为2种以上(含2种)低于100*/
 {
  printf("日用品\n");
  printf("________\n");
 }
 if((a[2]<100)&&(a[2]>=2))                               /*判断食品类库存量是否为2种以上(含2种)低于100*/
 {
  printf("食品\n");
  printf("________\n");
 }
 if((a[3]<100)&&(a[3]>=2))                              /*判断办公用品类库存量是否为2种以上(含2种)低于100*/
 {
  printf("办公用品\n");
  printf("________\n");
 }
}
int main(int argc, char* argv[])
{
 struct good *p1,*p2;             /*定义结构体指针类型*/ 
 while(1)
 {
  printf("***********************************************\n");
  printf("1 ----------输出查看或者修改已存信息-----------\n");
  printf("-----------------------------------------------\n");
  printf("2 -----重新输入新信息(并且删除原有信息)------\n");
  printf("-----------------------------------------------\n");
  printf("3 统计商品信息(如果您还没有查看过信息请先按1)\n"); 
  printf("-----------------------------------------------\n");
  printf("4 -------------------退出---------------------\n");
  printf("***********************************************\n");
  scanf("%d",&m);
  if(m==1)
   shuchu();         /*调用输出信息函数*/
  if(m==2)
  {
   system("cls");
   head=createlist();       /*调用建立链表函数*/ 
  }
  if(m==3)
  {
   printf("统计结果如下\n");  
   head=paixu(head);       /*调用链表排序函数*/        
   jisuan();          /*调用计算函数*/ 
   shunxudayin();        /*调用顺序打印函数*/ 
   tongji1();          /*调用统计1函数*/ 
   tongji2();          /*调用统计2函数*/ 
  }
  if(m==4)
  {
   p1=head;
   while(p1!=NULL)      /*判断遍历链表结束条件*/
   {
    p2=p1->next;
    free(p1);         /*释放空间*/
    p1=p2;
   }
   break;
  }
 }
 return 0;          /*结束程序*/
}
请采纳答案,支持我一下。
㈧ C语言程序设计 超市商品信息管理系统
假设某超市经营各种商品,每种商品包括以下信息:商品编号、商品名称、商品品牌、库存数量、售价、已售数量。系统的主要功能包括:1. 创建商品信息文件:根据提示输入若干商品的信息,并将信息保存至一个文件中。2. 商品进货管理:每次购入新商品,需按要求输入商品所含各项信息并存入商品信息文件中。如果已经存在该商品(以商品编号为准),则修改相应的库存数量信息,否则生成新的商品信息记录。3. 商品销售管理:每次有商品销售出去,则按要求输入商品编号和商品名称信息,并修改相应的商品信息文件。注意:商品销售时要检查库存数量的合法性(即销售出去的数量必须小于库存数量)。4. 按不同条件进行查询操作,输出满足条件的商品信息。(1) 输入商品名称,在商品信息文件中查找相应的商品信息并输出。(2) 输入商品品牌,在商品信息文件中查找该品牌的所有信息并输出。5. 按不同条件对商品信息进行统计工作。(1) 输入商品名称,在商品信息文件中统计该商品的销售总额。(2) 设置一个库存数量警戒值,输出库存数量小于该警戒值的所有库存商品的信息。(3) 输入商品品牌,在商品信息文件中统计其不同商品名称的库存量,并输出库存量最高的那个商品的信息。
㈨ C语言实现超市POS系统购买商品(名称单价数量)(不超过50样商品)购买清单输入总金额统计结算清单
语言实现超市POS系统购买商品(名称单价数量)(不超过50样商品
㈩ c语言超市管理系统
语言超市管理系统这样我理解可以写
