模拟“双骰子赌博”游戏,有错误,求指教
程序代码:
#include<stdio.h> #include<stdlib.h> #include<time.h> enum Status{ CONTINUE, WON, LOST}; int rollDice(void) int main(void) { int sum; int mypoint; enum Status gameStatus; srand(time(NULL)); sum=rollDice(); switch(sum){ case 7: case 11: gameStatus=WON; break; case 2: case 3: case 12: gameStatus=LOST; break; default: gameStatus=CONTINUE; mypoint=sum; break; } while(gameStatus==CONTINUE) { sum=rollDice(); if(sum==mypoint) gameStatus=WON; else{ if(sum==7) gameStatus=LOST; } } if(gameStatus==WON) { printf("Player wins\n"); } else { printf("Player loses\n"); } return 0; } int rollDice(void) { int die1,die2,workSum; die1=1+(rand()%6); die2=1+(rand()%6); workSum=die1+die2; printf("Player rolled %d + %d = %d \n",die1,die2,workSum); return workSum; }
这个错误是为什么呢?我用的是Dev C++