1、 i 3; +i) tji.jrxl = 0; tji.jrzje = 0; void main() /初始化 init(); int op = 0; /读取商品信息 loadGoodsFrom); char c = ChooseJieMian(); while(true) system(cls); if( c = 1) c = SaleCenter(); else if(c = 2 op = KouLing(); if(op = 1) /进入管理界面 c = ManageCenter(); /system(pause else if(op = 0) /进去销售界面 c = SaleCente
2、r(); /- /* * return 1销售界面 2管理界面 */ char SaleCenter() char state=N; int Sum=0; char Pro = d / printf(n*n while(true) state= Sum=0; while(!(Pro = c | Pro = abq) system( printf(nt*nt*顾客您好,请选择商品*nnta商品%s bcq管理n,goods0.name,goods1.name,goods2.name);nt -%d- -%d- -%d- (单位:件),goods0.totalCount,goods1.totalC
3、ount,goods2.totalCount);nt*ntt Pro = getchar(); if(Pro = ) break; switch(Pro) case : Sum=Sum+2; printf(商品A价格为%d,请投币,Sum); break;A Sum=Sum+3;商品B价格为%d,请投币B Sum=Sum+6;商品C价格为%d,请投币C break; default:nt输入物品有误!n break; ; int Money; bool st=false; while(!st) / printf(n输入金额: scanf(%d,&Money); getchar(); st=Ge
4、tCharge(Sum,Money); ; Pro = system(PAUSE return bool GetCharge(int Sum,int Money) int ChargeNum4; for(int i=0;iMoney) printf(所投金额不足支付所选商品,请重新投币 return false; else if(Sum=Money) 所投金额等于商品价格,请在商品出口处拿取商品 /销售成功的操作 if(Sum = goods0.price) goods0.totalCount -; Sale(); tj0.jrxl +; tj0.jrzje += Sum; else if(S
5、um = goods1.price) goods1.totalCount -; tj1.jrxl +; tj1.jrzje += Sum; else if(Sum = goods2.price) tj2.jrxl +; tj2.jrzje += Sum; return true; else int Result=Money-Sum; Getsmalcharge(Result,ChargeNum);所投金额大于商品价格,为您找零%d元,Result);ntt-壹元面值 %d张-n,ChargeNum0);ntt-贰元面值 %d张-n,ChargeNum1);ntt-伍元面值 %d张-n,Char
6、geNum2);ntt-拾元面值 %d张-n,ChargeNum3);请在商品出口处拿取商品n余额为%d元,应找零n1 元%d张n2 元%d张n5 元%d张n10元%d张n,Result,ChargeNum0,ChargeNum1,ChargeNum2,ChargeNum3); /end if /销售成功的操作 if(Sum = goods0.price) goods0.totalCount -; Sale(); tj0.jrxl +; tj0.jrzje += Sum; else if(Sum = goods1.price) goods1.totalCount -; tj1.jrxl +;
7、tj1.jrzje+= Sum; else if(Sum = goods2.price) goods2.totalCount -; tj2.jrxl +; tj2.jrzje+= Sum; return true; 成功卖出操作的后台操作 void Sale() FILE* fp; if (fp = fopen(d:goods.out, w) = NULL) printf (未找到文件d:goods.out.系统将退出n exit(0); fprintf(fp,%s %d %dn,goods0.name,goods0.totalCount,goods0.price);,goods1.name,
8、goods1.totalCount,goods1.price);,goods2.name,goods2.totalCount,goods2.price); /关闭文件 fclose(fp); fp = NULL; /- void Getsmalcharge(int Money,int *ChargeNum) if(Money0) return; int Sum=Money; int charge4=1,2,5,10; ChargeNum3=Sum/charge3; Sum=Sum%charge3; ChargeNum2=Sum/charge2; Sum=Sum%charge2; ChargeNum1=Sum/charge1; Sum=Sum%charge1; ChargeNum0=Sum/charge0; Sum=Sum%charge
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1