标题: 自己编了个小程序,大家帮忙看看,互相学习 [打印本页] 作者: 事实和胜利 时间: 2011-8-19 11:33 标题: 自己编了个小程序,大家帮忙看看,互相学习 #include <stdio.h>
void main()
{char goods='a';
int money=0;
int balance=0;
char choise='N';
while(1)
{printf("please enter goods that you want to buy\n");
scanf(" %c",&goods);
if((goods!='a')&&(goods!='b')&&(goods!='c')&&(goods!='d')&&(goods!='e')) {printf("please choose your goods again\n");continue;};
printf("please drop your money\n");
scanf(" %d",&money);
if(money==1)
{if(goods=='a') balance=0;
else balance=-1;
}
else
if(money==10)
{switch(goods)
{case 'a':balance=9;break;
case 'b':balance=7;break;
case 'c':balance=7;break;
case 'd':balance=7;break;
case 'e':balance=3;break;
default:balance=-1;
}
}
else
{printf("your money isn't available\n");continue;};