我写了一个市场计划,可以总结您所购买商品的价格。现在,我还想在最后打印选择的项目和数量。我该怎么办?
#include <stdio.h>
int main() {
int c,l=0,b=0,q=0;
float sum=0;
printf("Welcome to MH-Mart\n");
while (l<1) {
printf("1.Bread\n");
printf("Select a Category(If your done enter 11):\n");
scanf("%d",&c);
if(c==11){
printf("YOUR TOTAL SUM=%f\n",sum);
return 0;
break;
}
if (c==1) {
printf("Bread:\n1.Pita 1=1₪״\n2.Baguette 1=2.5₪
\n3.WhiteBread1=1.5₪\nPlease select what you want:\n");
scanf("%d",&b);
printf("How many you want:\n");
scanf("%d",&q);
if(b==1){
sum=sum+(q*1);
}
if(b==2){
sum=sum+(q*2.5);
}
if(b==3){
sum=sum+(q*1.5);
}
}
}
}