自动售货机销售系统 C

来源:互联网 发布:Windows 10专业版64位 编辑:程序博客网 时间:2024/05/01 19:47
  1. /*前言:
  2. 进入管理界面的密码为:206;
  3. 销售日志记录在sale.log中,售货机中的零钞数量记录在change.log中,
  4. 售货机中的商品信息(包括状态(上架或下架,上架记录为1,下架记录为0),
  5. 数量,编号和价格)记录在saleinfo.log中;
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <time.h>
  11. #include <conio.h>
  12. void xsjm(void); /*销售界面函数*/
  13. void lcjm(void); /*零钞界面函数*/
  14. void gljm(void); /*管理界面函数*/
  15. void InputSale(FILE *fp); /*商品上架函数*/
  16. void InputChange(FILE *fp2); /*设置零钞数目函数*/
  17. void RemoveSale(FILE *fp); /*商品下架函数*/
  18. void Account(int chos1, int chos2, FILE *fp, FILE *fp2, FILE *fp3); /*商品交易计算函数*/
  19. void Search(FILE *fp3); /*打印销售日志函数*/
  20. void Stat(FILE *fp2); /*查询零钞数目和销售额函数*/
  21. void Stat_2(FILE *fp3); /*销售统计函数*/
  22. #define MAX 100 /*定义sale.log中最多存储100条销售记录*/
  23. struct SALE    /*定义商品结构*/
  24. {
  25.     int state;   /*自定义1或0,初始化为0*/
  26.     int amount;  /*自定义,初始化为0*/
  27.     int num;     /*1,2,3,4*/
  28.     int price;   /*1,2,5,5*/
  29. }sale[4]={{0,0,1,1},{0,0,2,2},{0,0,3,5},{0,0,4,5}};
  30. struct TIME
  31. {
  32.     int month;
  33.     char eng_month[5];
  34. }times[12]={{1,"Jan"},{2,"Feb"},{3,"Mar"},{4,"Apr"},{5,"May"},{6,"Jun"},
  35. {7,"Jul"},{8,"Aug"},{9,"Sep"},{10,"Oct"},{11,"Nov"},{12,"Dec"}};
  36. int change[3]={{0},{0},{0}}; 
  37. main()
  38. {   
  39.     int choose, choose1, choose2;
  40.     FILE *fp, *fp2, *fp3;
  41.     xsjm();
  42.     scanf("%d", &choose1);
  43.     while (choose1!=0)
  44.     {
  45.         if (choose1==206)/*如果输入206则进入管理界面*/
  46.         {
  47.             system("cls");
  48.             gljm();
  49.             scanf("%d", &choose);
  50.             while (choose!=0)
  51.             {
  52.                 switch (choose)
  53.                 {
  54.                 case 1:
  55.                     if ((fp=fopen("saleinfo.log","r+"))==NULL)
  56.                     {
  57.                         printf("open saleinfo.log fail!/n");
  58.                     }
  59.                     InputSale(fp);
  60.                     fclose(fp);
  61.                     break;
  62.                 case 2:
  63.                     if ((fp2=fopen("change.log","r+"))==NULL)
  64.                     {
  65.                         printf("open change.log fail!/n");
  66.                     }
  67.                     InputChange(fp2);
  68.                     fclose(fp2);
  69.                     break;
  70.                 case 3:
  71.                     if ((fp2=fopen("change.log","r+"))==NULL)
  72.                     {
  73.                         printf("open change.log fail!/n");
  74.                     }
  75.                     Stat(fp2);
  76.                     printf("Press any key to continue.../n");
  77.                     getch();
  78.                     fclose(fp2);
  79.                     break;
  80.                 case 4:
  81.                     if ((fp3=fopen("sale.log","r"))==NULL)
  82.                     {
  83.                         printf("open sale.log fail!/n");
  84.                     }
  85.                     Search(fp3);
  86.                     printf("Press any key to continue.../n");
  87.                     getch();
  88.                     fclose(fp3);
  89.                     break;
  90.                 case 5:
  91.                     if ((fp=fopen("saleinfo.log","r+"))==NULL)
  92.                     {
  93.                         printf("open saleinfo.log fail!/n");
  94.                     }
  95.                     RemoveSale(fp);
  96.                     printf("商品下架成功!/n");
  97.                     printf("Press any key to continue.../n");
  98.                     getch();
  99.                     fclose(fp);
  100.                     break;
  101.                 case 6:
  102.                     if ((fp3=fopen("sale.log","r"))==NULL)
  103.                     {
  104.                         printf("open sale.log fail!/n");
  105.                     }
  106.                     Stat_2(fp3);
  107.                     printf("Press any key to continue.../n");
  108.                     getch();
  109.                     fclose(fp3);
  110.                     break;
  111.                 default:
  112.                     printf("Input error!Press any key to continue.../n");
  113.                     getch();
  114.                 }
  115.                 system("cls");
  116.                 gljm();
  117.                 scanf("%d", &choose);
  118.             }
  119.         }
  120.         if (choose1==1||choose1==2||choose1==3||choose1==4)
  121.         {
  122.             system("cls");
  123.             lcjm();
  124.             scanf("%d", &choose2);
  125.             switch (choose2)
  126.             {
  127.             case 1:
  128.             case 2:
  129.             case 3:
  130.             case 4:
  131.             case 5:
  132.                 if ((fp=fopen("saleinfo.log","r+"))==NULL)
  133.                 {
  134.                     printf("open saleinfo.log fail!/n");
  135.                 }
  136.                 if ((fp2=fopen("change.log","r+"))==NULL)
  137.                 {
  138.                     printf("open change.log fail!/n");
  139.                 }
  140.                 if ((fp3=fopen("sale.log","a+"))==NULL)
  141.                 {
  142.                     printf("open sale.log fail!/n");
  143.                 }
  144.                 Account(choose1, choose2, fp, fp2, fp3);
  145.                 printf("Press any key to continue...");
  146.                 getch();
  147.                 fclose(fp);
  148.                 fclose(fp2);
  149.                 fclose(fp3);
  150.                 break;
  151.             default:
  152.                 printf("Input error!Press any key to continue.../n");
  153.                 getch();
  154.                 break;
  155.             }
  156.         }
  157.         system("cls");
  158.         xsjm();
  159.         scanf("%d", &choose1);
  160.     }
  161. }
  162. void Stat_2(FILE *fp3)
  163. {
  164.     int i, j, num[MAX], sort[MAX] , amount[MAX], out_1[MAX], out_5[MAX], year[MAX], date[MAX];
  165.     int lines=0;
  166.     int month_2[MAX];
  167.     int start_year, start_month, start_date, end_year, end_month, end_date;
  168.     int sold_1=0,sold_2=0,sold_3=0,sold_4=0;
  169.     int start=-1, end=-1;
  170.     char week[MAX][5], month[MAX][5], time[MAX][10];
  171.     fseek(fp3, 0, 0);
  172.     for (i=0; !feof(fp3)&&i<MAX; i++)
  173.     {
  174.         fscanf(fp3, "%d/t/t%d/t%d/t%d/t%d/t%s %s %d %s %d/n",&num[i], &sort[i],
  175.             &amount[i], &out_1[i], &out_5[i],&week[i], &month[i],
  176.             &date[i],&time[i], &year[i]);
  177.         lines++;
  178.     }
  179.     for (i=0; i<lines; i++)
  180.     {
  181.         for (j=0; j<12; j++)
  182.         {
  183.             if(strcmp(month[i],times[j].eng_month)==0)
  184.                 month_2[i]=times[j].month;
  185.         }
  186.     }
  187.     printf("请输入统计开始时间:/n例如 2008年3月2日则输入:2008,03,02/n:");
  188.     scanf("%d,%d,%d", &start_year, &start_month, &start_date);
  189.     printf("请输入统计结束时间:");
  190.     scanf("%d,%d,%d", &end_year, &end_month, &end_date);
  191.     for (i=0; i<lines; i++)
  192.     {
  193.         if (start_year==year[i]&&start_month==month_2[i]&&start_date==date[i])
  194.         {
  195.                 start=i;
  196.                 break;
  197.         }
  198.     }
  199.     for (i=0; i<lines; i++)
  200.     {
  201.         if (end_year==year[i]&&end_month==month_2[i]&&end_date==date[i])
  202.         {
  203.                 end=i;
  204.         }
  205.     }
  206.     if (start==-1||end==-1||start>end)
  207.     {
  208.         printf("Input error or date not exist!/n");
  209.         return;
  210.     }
  211.     for (i=start; i<=end; i++)
  212.     {
  213.         if (num[i]==1)
  214.             sold_1++;
  215.         if (num[i]==2)
  216.             sold_2++;
  217.         if (num[i]==3)
  218.             sold_3++;
  219.         if (num[i]==4)
  220.             sold_4++;
  221.     }
  222.     printf("商品1卖出数量%d,销售额为%d/n", sold_1, sold_1*sale[0].price);
  223.     printf("商品2卖出数量%d,销售额为%d/n", sold_2, sold_2*sale[1].price);
  224.     printf("商品3卖出数量%d,销售额为%d/n", sold_3, sold_3*sale[2].price);
  225.     printf("商品4卖出数量%d,销售额为%d/n", sold_4, sold_4*sale[3].price);
  226. }
  227. void Stat(FILE *fp2)
  228. {
  229.     int i, sum;
  230.     printf("对帐:/n");
  231.     for (i=0; i<3; i++)
  232.     {
  233.         fscanf(fp2, "%5d/n", &change[i]);
  234.     }
  235.     fscanf(fp2, "%5d/n", ∑);
  236.     printf("当前1元数量为%d,5元数量为%d,10元数量为%d./n", change[0],change[1],change[2]);
  237.     printf("销售总额为%d/n", sum);
  238. }
  239. void Search(FILE *fp3)
  240. {
  241.     char ch;
  242.     int *p=NULL;
  243.     int i, j, k, choose, num[MAX], sort[MAX] , amount[MAX], out_1[MAX], out_5[MAX], year[MAX];
  244.     int lines=0, TempInt;
  245.     char TempChar[10];
  246.     char week[MAX][5], date[MAX][5], month[MAX][5], time[MAX][10];
  247.     printf("销售日志:/n");/*打印销售日志*/
  248.     while(!feof(fp3))
  249.     {   
  250.         ch=fgetc(fp3);
  251.         putchar(ch);
  252.     }
  253.     p=(int*)malloc(sizeof(int)*MAX);
  254.     fseek(fp3, 0, 0);
  255.     for (i=0; !feof(fp3); i++)
  256.     {
  257.         fscanf(fp3, "%d/t/t%d/t%d/t%d/t%d/t%s %s %s %s %d/n",&num[i], &sort[i],
  258.             &amount[i], &out_1[i], &out_5[i],&week[i], &month[i],
  259.             &date[i],&time[i], &year[i]);
  260.         lines++;
  261.     }
  262.     printf("请选择:1.用选择法排序 2.用交换法排序:");
  263.     scanf("%d", &choose);
  264.     while (choose!=1&&choose!=2)
  265.     {
  266.         printf("输入错误!/n");
  267.         printf("请选择:1.用选择法排序 2.用交换法排序:");
  268.         scanf("%d", &choose);
  269.     }
  270.     switch (choose)
  271.     {
  272.     case 1:
  273.         for (i=0; i<lines-1; i++)
  274.         {
  275.             k=i;
  276.             for (j=i+1; j<lines; j++)
  277.             {
  278.                 if (num[j]<num[k])
  279.                 {
  280.                     k=j;
  281.                 }
  282.             }
  283.             if (k!=i)
  284.             {
  285.                 TempInt=num[k];
  286.                 num[k]=num[i];
  287.                 num[i]=TempInt;
  288.                 
  289.                 TempInt=sort[k];
  290.                 sort[k]=sort[i];
  291.                 sort[i]=TempInt;
  292.                 
  293.                 TempInt=amount[k];
  294.                 amount[k]=amount[i];
  295.                 amount[i]=TempInt;
  296.                 
  297.                 TempInt=out_1[k];
  298.                 out_1[k]=out_1[i];
  299.                 out_1[i]=TempInt;
  300.                 
  301.                 TempInt=out_5[k];
  302.                 out_5[k]=out_5[i];
  303.                 out_5[i]=TempInt;
  304.                 
  305.                 strcpy(TempChar,week[k]);
  306.                 strcpy(week[k],week[i]);
  307.                 strcpy(week[i],TempChar);
  308.                 
  309.                 strcpy(TempChar,month[k]);
  310.                 strcpy(month[k],month[i]);
  311.                 strcpy(month[i],TempChar);
  312.                 
  313.                 strcpy(TempChar,date[k]);
  314.                 strcpy(date[k],date[i]);
  315.                 strcpy(date[i],TempChar);
  316.                 
  317.                 strcpy(TempChar,time[k]);
  318.                 strcpy(time[k],time[i]);
  319.                 strcpy(time[i],TempChar);
  320.                 
  321.                 TempInt=year[k];
  322.                 year[k]=year[i];
  323.                 year[i]=TempInt;
  324.             }
  325.         }
  326.         for (i=0; i<lines; i++)
  327.         {
  328.             printf("%d/t/t%d/t%d/t%d/t%d/t%s %s %s %s %d/n",num[i], sort[i],
  329.                 amount[i], out_1[i], out_5[i],week[i], month[i],
  330.                 date[i],time[i], year[i]);
  331.         }
  332.         break;
  333.     case 2:
  334.         for (i=0; i<lines-1; i++)
  335.         {
  336.             for (k=i+1; k<lines; k++)
  337.             {
  338.                 if (num[k]<num[i])
  339.                 {
  340.                     TempInt=num[k];
  341.                     num[k]=num[i];
  342.                     num[i]=TempInt;
  343.                     
  344.                     TempInt=sort[k];
  345.                     sort[k]=sort[i];
  346.                     sort[i]=TempInt;
  347.                     
  348.                     TempInt=amount[k];
  349.                     amount[k]=amount[i];
  350.                     amount[i]=TempInt;
  351.                     
  352.                     TempInt=out_1[k];
  353.                     out_1[k]=out_1[i];
  354.                     out_1[i]=TempInt;
  355.                     
  356.                     TempInt=out_5[k];
  357.                     out_5[k]=out_5[i];
  358.                     out_5[i]=TempInt;
  359.                     
  360.                     strcpy(TempChar,week[k]);
  361.                     strcpy(week[k],week[i]);
  362.                     strcpy(week[i],TempChar);
  363.                     
  364.                     strcpy(TempChar,month[k]);
  365.                     strcpy(month[k],month[i]);
  366.                     strcpy(month[i],TempChar);
  367.                     
  368.                     strcpy(TempChar,date[k]);
  369.                     strcpy(date[k],date[i]);
  370.                     strcpy(date[i],TempChar);
  371.                     
  372.                     strcpy(TempChar,time[k]);
  373.                     strcpy(time[k],time[i]);
  374.                     strcpy(time[i],TempChar);
  375.                     
  376.                     TempInt=year[k];
  377.                     year[k]=year[i];
  378.                     year[i]=TempInt;
  379.                 }
  380.             }
  381.         }
  382.         for (i=0; i<lines; i++)
  383.         {
  384.             printf("%d/t/t%d/t%d/t%d/t%d/t%s %s %s %s %d/n",num[i], sort[i],
  385.                 amount[i], out_1[i], out_5[i],week[i], month[i],
  386.                 date[i],time[i], year[i]);
  387.         }
  388.         break;
  389.     }
  390.     free(p);
  391. }
  392. void Account(int chos1, int chos2, FILE *fp, FILE *fp2, FILE *fp3)
  393. {
  394.     time_t t;
  395.     int i, pri=0, diff=0, innum, into, sum=0;
  396.     char name[10];
  397.     int out_1=0, out_5=0;
  398.     pri=sale[chos1-1].price;
  399.     switch(chos1)
  400.     {
  401.     case 1:
  402.         strcpy(name, "糖果");
  403.         break;
  404.     case 2:
  405.         strcpy(name, "饼干");
  406.         break;
  407.     case 3:
  408.         strcpy(name, "可乐");
  409.         break;
  410.     case 4:
  411.         strcpy(name, "雪碧");
  412.         break;
  413.     }
  414.     for (i=0; i<4; i++)
  415.     {
  416.         fscanf(fp, "%5d %5d %5d %5d/n", &sale[i].state,&sale[i].amount,&sale[i].num,&sale[i].price);
  417.     }
  418.     for (i=0; i<3; i++)
  419.     {
  420.         fscanf(fp2, "%5d/n", &change[i]);
  421.     }
  422.     fscanf(fp2, "%5d/n", ∑);
  423.     if (sale[chos1-1].amount==0||sale[chos1-1].state==0)
  424.     {
  425.         printf("该商品已经售完或下架,交易失败。。。/n");
  426.         return;
  427.     }
  428.     switch (chos2)    /*按菜单计算用户投入零钱*/
  429.     {
  430.     case 1:
  431.         into=1;
  432.         innum=1;
  433.         break;
  434.     case 2:
  435.         into=1;
  436.         innum=2;
  437.         break;
  438.     case 3:
  439.         into=1;
  440.         innum=5;
  441.         break;
  442.     case 4:
  443.         into=5;
  444.         innum=1;
  445.         break;
  446.     case 5:
  447.         into=10;
  448.         innum=1;
  449.         break;
  450.     }
  451.     diff=into*innum-pri;    /*计算投入零钱与商品价格的差价*/
  452.     if (diff<0)
  453.     {
  454.         printf("投入现金太少,交易失败。。。/n");
  455.         return;
  456.     }
  457.     else if (diff<5)
  458.     {
  459.         if (change[0]>=diff)
  460.         {
  461.             out_1=diff;
  462.             change[0]-=out_1;
  463.             switch (into)
  464.             {
  465.             case 1:
  466.                 if (innum==1)
  467.                     change[0]+=1;
  468.                 if (innum==2)
  469.                     change[0]+=2;
  470.                 if (innum==5)
  471.                     change[0]+=5;
  472.                 break;
  473.             case 5:
  474.                 change[1]+=1;
  475.                 break;
  476.             case 10:
  477.                 change[2]+=1;
  478.                 break;
  479.             }
  480.             fseek(fp2,0, 0);
  481.             fprintf(fp2, "%5d/n", change[0]);
  482.             fseek(fp2,1*7, 0);
  483.             fprintf(fp2, "%5d/n", change[1]);
  484.             fseek(fp2,2*7, 0);
  485.             fprintf(fp2, "%5d/n", change[2]);
  486.             fseek(fp,(chos1-1)*25, 0);
  487.             fprintf(fp,"%5d %5d %5d %5d/n",sale[chos1-1].state, sale[chos1-1].amount-1,sale[chos1-1].num,sale[chos1-1].price);
  488.             time(&t);
  489.             fprintf(fp3,"%d/t/t%2d/t%d/t%d/t%d/t%s",sale[chos1-1].num,into,innum,out_1,out_5,ctime(&t));
  490.             sum+=sale[chos1-1].price;
  491.             fseek(fp2, 3*7, 0);
  492.             fprintf(fp2, "%5d/n", sum);
  493.             printf("交易成功!已吐出%s商品!找您%d元!包括%d张1元,%d张5元。/n", name, diff, out_1, out_5);    
  494.             return;
  495.         }
  496.         else
  497.         {
  498.             printf("售货机内零钱不足,交易失败。。。/n");
  499.             return;
  500.         }
  501.     }
  502.     else 
  503.     {
  504.         if (change[1]!=0)
  505.         {
  506.             if (change[0]>=(diff-5))
  507.             {
  508.                 out_5=1;
  509.                 out_1=diff-5;
  510.                 change[1]-=out_5;
  511.                 change[0]-=out_1;
  512.     
  513.                 switch (into)
  514.                 {
  515.                 case 1:
  516.                     if (innum==1)
  517.                         change[0]+=1;
  518.                     if (innum==2)
  519.                         change[0]+=2;
  520.                     if (innum==5)
  521.                         change[0]+=5;
  522.                     break;
  523.                 case 5:
  524.                     change[1]+=1;
  525.                     break;
  526.                 case 10:
  527.                     change[2]+=1;
  528.                     break;
  529.                 }               
  530.                 fseek(fp2,0, 0);
  531.                 fprintf(fp2, "%5d/n", change[0]);
  532.                 fseek(fp2,1*7, 0);
  533.                 fprintf(fp2, "%5d/n", change[1]);
  534.                 fseek(fp2,2*7, 0);
  535.                 fprintf(fp2, "%5d/n", change[2]);
  536.                 
  537.                 fseek(fp,(chos1-1)*25, 0);
  538.                 fprintf(fp,"%5d %5d %5d %5d/n",sale[chos1-1].state, sale[chos1-1].amount-1,sale[chos1-1].num,sale[chos1-1].price);
  539.                 time(&t);
  540.                 fprintf(fp3,"%d/t/t%d/t%d/t%d/t%d/t%s",sale[chos1-1].num,into,innum,out_1,out_5,ctime(&t));
  541.                 sum+=sale[chos1-1].price;
  542.                 fseek(fp2, 3*7, 0);
  543.                 fprintf(fp2, "%5d/n", sum);
  544.                 printf("交易成功!已吐出%s商品!找您%d元!包括%d张1元,%d张5元。/n", name, diff, out_1, out_5);    
  545.                 return;
  546.             }
  547.             else 
  548.             {
  549.                 printf("售货机内零钱不足,交易失败。。。/n");
  550.                 return;
  551.             }
  552.         }
  553.         else
  554.         {
  555.             printf("售货机内零钱不足,交易失败。。。/n");
  556.             return;
  557.         }
  558.     }
  559. }
  560. /*商品上架函数*/
  561. void InputSale(FILE *fp)
  562. {
  563.     int num, amount;
  564.     printf("请输入上架商品编码(1,2,3,4):");
  565.     scanf("%d", &num);
  566.     while (num!=1&&num!=2&&num!=3&&num!=4)
  567.     {
  568.         printf("输入错误!/n");
  569.         printf("请输入上架商品编码(1糖果,2饼干,3可乐,4雪碧):");
  570.         scanf("%d", &num);
  571.     }
  572.     fseek(fp,(num-1)*25, 0);
  573.     fscanf(fp, "%5d %5d %5d %5d/n", &sale[num-1].state,&sale[num-1].amount,&sale[num-1].num,&sale[num-1].price);
  574.     printf("当前该商品数量为:%d/n", sale[num-1].amount);
  575.     printf("请输入要设置的数量:", num);
  576.     scanf("%d", &amount);
  577.     while (amount<0||amount>10000)
  578.     {
  579.         printf("输入数目太大或太小!/n");
  580.         printf("请输入要设置的数量:", num);
  581.         scanf("%d", &amount);
  582.     }
  583.     sale[num-1].amount=amount;
  584.     sale[num-1].state=1;
  585.     fseek(fp,(num-1)*25, 0);
  586.     fprintf(fp,"%5d %5d %5d %5d/n",sale[num-1].state, sale[num-1].amount,sale[num-1].num,sale[num-1].price);
  587.     system("cls");
  588. }
  589. /*零钞设置函数*/
  590. void InputChange(FILE *fp2)
  591. {
  592.     int i, sort, amount, num;
  593.     printf("请输入货币面额(1, 5, 10):");
  594.     scanf("%d", &sort);
  595.     while (sort!=1&&sort!=5&&sort!=10)
  596.     {
  597.         printf("输入错误!/n");
  598.         printf("请输入货币面额(1, 5, 10):");
  599.         scanf("%d", &sort);
  600.     }
  601.     switch (sort)
  602.     {
  603.     case 1:
  604.         num=0;
  605.         break;
  606.     case 5:
  607.         num=1;
  608.         break;
  609.     case 10:
  610.         num=2;
  611.         break;
  612.     }
  613.     for (i=0; i<3; i++)
  614.     {
  615.         fscanf(fp2, "%5d/n", &change[i]);
  616.     }
  617.     printf("当前%d元数量为%d/n", sort, change[num]);
  618.     printf("请输入该货币数量:");
  619.     scanf("%d", &amount);
  620.     change[num]=amount;
  621.     while (amount<0||amount>10000)
  622.     {
  623.         printf("输入数目太大或太小!/n");
  624.         printf("请输入该货币数量:");
  625.         scanf("%d", &amount);
  626.     }
  627.     
  628.     fseek(fp2, num*7, 0);
  629.     fprintf(fp2, "%5d/n", change[num]);
  630.     system("cls");
  631. }
  632. /*商品下架函数*/
  633. void RemoveSale(FILE *fp)
  634. {
  635.     int num, i;
  636.     printf("请输入要下架的商品编号(1,2,3,4):");
  637.     scanf("%d", &num);
  638.     while (num!=1&&num!=2&&num!=3&&num!=4)
  639.     {
  640.         printf("输入错误!/n");
  641.         printf("请输入要下架的商品编号(1,2,3,4):");
  642.         scanf("%d", &num);
  643.     }
  644.     sale[num-1].state=0;
  645.     for (i=0; i<4; i++)
  646.     {
  647.         fprintf(fp,"%d %d %d %d/n",sale[i].state, sale[i].amount,sale[i].num,sale[i].price);
  648.     }
  649.     system("cls");
  650. }
  651. /*销售界面*/
  652. void xsjm(void)
  653. {
  654.     printf("    进入管理界面密码:206/n");
  655.     printf("*********销售界面************/n");
  656.     printf("* 请选择您要购买的商品!    */n");
  657.     printf("* 1. 糖果      1元          */n");
  658.     printf("* 2. 饼干      2元          */n");
  659.     printf("* 3. 可乐      5元          */n");
  660.     printf("* 4. 雪碧      5元          */n");
  661.     printf("* 0. 退出程序               */n");
  662.     printf("*****************************/n");
  663. }
  664. /*零钞界面*/
  665. void lcjm(void)
  666. {
  667.     printf("*********零钞界面************/n");
  668.     printf("* 请选择投入零钞类型及界面!*/n");
  669.     printf("* 1. 1元 * 1                */n");
  670.     printf("* 2. 1元 * 2                */n");
  671.     printf("* 3. 1元 * 5                */n");
  672.     printf("* 4. 5元 * 1                */n");
  673.     printf("* 5. 10元 * 1               */n");
  674.     printf("* 0. 返回销售界面           */n");
  675.     printf("*****************************/n");
  676. }
  677. /*管理界面*/
  678. void gljm(void)
  679. {
  680.     printf("**********管理界面***********/n");
  681.     printf("* 1. 商品上架               */n");
  682.     printf("* 2. 零钞设置               */n");
  683.     printf("* 3. 对帐功能               */n");
  684.     printf("* 4. 销售日志查询           */n");
  685.     printf("* 5. 商品下架               */n");
  686.     printf("* 6. 销售统计               */n");
  687.     printf("* 0. 返回销售界面           */n");
  688.     printf("*****************************/n");
  689. }