#include<stdio.h>
int main(void)
{
float a,b,c,w,y,z;
a=b=c=0;
float num , A,B,C;
char ch;
printf(“Please enter letter to buy things(q to quit):\n”);
printf(" letter:a b c \n thing :YJ TC HLB \nprice(perB):2.05 1.15 1.09\n");
printf(“How many pounds do you need for”);
ch = getchar();
while((ch >= ‘a’ && ch<=‘c’) || ch == ‘q’)
{
switch(ch)
{
case ‘a’:printf(“YJ:”);
scanf("%f", &w);
getchar();//将回车键清除
a += w;
break;
case ‘b’:printf(“YJ:”);
scanf("%f", &y);
getchar();
b += y;
break;
case ‘c’:printf(“YJ:”);
scanf("%f", &z);
getchar();
c += z;
break;
case ‘q’:goto end;//goto与目标之间不能再声明变量
}
printf(“Please enter letter again to
每日代码1
最新推荐文章于 2024-07-11 09:47:07 发布