0

how repair the faild?

#include<iostream>
      using namespace std;
	  #include<ctime>
      int rolldice(void)
      int main()
      {
		  enum status {continuo,won,lost}
		  int sum , mypoint;
          status gamestate;
		  srand(tim(0))
		  sum=rolldice();
		  switch (sum)
		  {case 7;
           case 11;
          gamestate=won;
		  break;
           case 2;
           case 3;
	       case 12;
          gamestate=lost;
		  break;
		  default;
			  gamestate=continuo;
			  mypoint=sum;
				  cout<<"enter:"<<endl;
			    break;
				while (gamestate==continuo){
					sum=rolldice();
				if(sum=mypoint)
					 gamestate=won;
				else
					if(sum=7)
						gamestate=lost;}}}
		   int rolldice(void)
		   {
			   int die 1,die 2,worhsum;
			   die 1=1+rand()%6;
			    die 2=1+rand()%6;
				worhsum=die 1+die 2;
				return worhsum;}
2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by jonsca
0

First, you need to learn how to format your code. Good that you got the code tags but what you have looks terrible and is hard to follow. Give this article a read: http://www.gidnetwork.com/b-38.html

Secondly, your switch syntax is completely wrong, you need colons after the cases not semicolons:

switch(sum)
{
     case 7:  //code for case 7
                 break;
     case 11: //code for case 11
                  break;
     
    // (etc.)
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.