繼續說else語句出現錯誤,並且應該在else之前出現錯誤。 我不能真正弄明白什麼是錯 如果有人可以幫助我走出這將是巨大修復它出現的代碼,在'else'之前說錯誤預期表達式
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int random1_6()
{
return ((rand() % 6) + 1);
}
int main(void)
{
int a, b, c, d, equal, sum;
srand(time(NULL));
a = random1_6();
b=random1_6();
sum = a + b;
printf("\n The player rolled: %d + %d = %d. \n the players point is %d. \n", a, b, sum, sum);
if (sum ==7);
{
printf("The player wins. \n");
}
else (sum !=7);
{
c = random1_6();
d=random1_6();
equal = c + d;
printf("\n The player rolled: %d + %d = %d", c, d, equal);
}
刪除''你else語句。 – claudios
您還必須在if(sum == 7)之後移除逗號(;); – Carlo