编了个玩骰子游戏,但是不能循环下注, 就是说只运行一下才能压一下注,请帮我加一个循环,谢谢.
#include"stdio.h"
#include"stdlib.h"
#include"time.h"
int rollDice(void);
main()
{
int sum;/*骰子点数*/
int m;/*下注金额*/
int i=500;/*原始金额*/
printf("****************\nwelcome to this game\n****************\n");
printf("you have 500$ now");
printf("please chip in\n");
if(i>0)
{
scanf("%d",&m);
srand(time(NULL));
sum=rollDice();
switch(sum)
{
case 1:
case 2:
case 3:
i=i-m;
printf("you lost\n");
printf("your money is %d\n",i);
break;
case 4:
case 5:
case 6:
i=i+m;
printf("you won\n");
printf("you money is %d\n",i);
break;
}
}
else of(i<=0)
printf("you have not money now\n");
printf("please chip in\n");
}
int rollDice(void)
{
int del;
del=1+(rand()%6);
printf("you del is%d\n",del);
return del;
}