不知道哪里出错了,请大神提示下,看了好久了,感觉是括号的问题,但不知道怎么改
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
main()
{
int rollDice();
void delay();
int i,result = 0 ,result1 = 0;
printf("Game Start!!!!\n");
result = rollDice();
printf("%d\n",result);
delay();
if ((result == 7 )||(result == 11))
{printf("Y\n");break;}
else if ((result == 2) || (result == 3)|| (result == 12))
{printf("N\n");}
else
printf("C\n");
for (i = 0;i<7;i++)
{result1 = rollDice();
printf("%d\n",result1);
if (result1==result)
{printf("Y\n");break;}
else if ((result1!=result)&&(i==6))
printf("N\n");
}
return 0;
}
int rollDice()
{
void delay();
int a,b,c;
srand((unsigned)time(NULL));
a= rand()%6 + 1;
delay();
b= rand()%6 + 1;
c = a + b;
return c;
}
void delay()
{
long t;
for (t=0;t<50000000;t++)
{
}
}
第一个break使用不恰当,必须在循环里面才能使用break。第二个break就可以。建议你代码格式统一,有花括号就统一加花括号。代码改成这样: