佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

楼主: Wongkokchoy

Asignment新的小问题。。。

[复制链接]
发表于 11-10-2008 08:50 AM | 显示全部楼层

回复 140# lliioonn 的帖子

大概30分钟吧。。。
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 11-10-2008 09:49 AM | 显示全部楼层
噢,原来是逻辑上的问题啊,真是的,我以为电脑跟我闹别扭

做到蒙擦擦了。。。。。。

我又为我的program作了一些改进, 就是说如果其中一个player quit game了,其他player还可以continue玩,
大致上已经完成了, 只剩下一行还没解决, 就是
next=x+1;
           if (next>=n)
           next=0;
           cout<<"\n\n\n\n"<<name[(next)]<<"'s turn!!!\n\n\n\n\n\n";
大大有什么建议吗?

[ 本帖最后由 Wongkokchoy 于 11-10-2008 10:25 AM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 11-10-2008 10:26 AM | 显示全部楼层
  1. #include <iostream.h>             // header file
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <time.h>
  5. #include <ctype.h>

  6. void Line();                     // function phototypes
  7. void Ladder(char[]);
  8. void Snake(char[]);
  9. void wall();
  10. void winner(int, char[]);

  11. void main()
  12. {
  13.     char dice, **name;                                      // declaration of variable
  14.     int A, n, number, next, x, reverse, *player, *cont;
  15.     Line();                                         // function call
  16.    
  17.     cout<<"\t\tWelcome to Snake and Ladder Game!!\n\n";            // instuction
  18.     cout<<"Introduction: if a player reach a point where there is a ladder, he/she will \nraise to a higher location.\n";
  19.     cout<<"\nOn the other hand, if the player reach a spot where there is a snake over there,the player will drop to a lower location.\n\n";
  20.     cout<<"The 1st player who reach 100 first will be the WINNER!!!!!!\n";
  21.     Line();                                        // function call

  22.     do                                                // do-while loop to avoid user to key in negative value or zero
  23.     {
  24.     cout<<"\nPlease enter the numbers of players:\n";
  25.     cin>>n;
  26.     cin.get();
  27.     if (n<=0)
  28.     cout<<"INVALID number of player!\n";
  29.     }
  30.     while (n<=0);
  31.     player=new int [n];             // declare array "player" and "name"
  32.     name=new char* [n];
  33.     cont=new int [n];
  34.     for(int i = 0; i < n ;i++)
  35.     name = new char[100];
  36.     for (int x=0; x
  37.     {
  38.     cout<<"lease enter player "<<(x+1)<<"'s name.\n";     //records players' name

  39.     cin.getline (name[x], 100);
  40.     }
  41.     for (int x=0; x
  42.     {
  43.     cout<<"layer "<<(x+1)<<"'s name is "<<<".\n";
  44.     }
  45.     cout<<"\nSo there will be "<<<" player(s) in the game.\n";
  46.     cout<<"There are ladders at 4, 9, 19, 21, 28, 51, 71. 80 \n(80 will directly send you to the vitory!!)\n";
  47.     cout<<"Snakes located at 17, 54, 62, 64, 87, 93, 96, 98.\n\n";
  48.     cout<<"(All players start at 0)\n\n\n";
  49.     cout<<"Good Luck and Have Fun!!!\n\n";
  50.     Line();                      // funciton call
  51.     for (x = 0; x < n; x++)    // sets all cell values in the array player to 0
  52.     {
  53.     player[x] = 0;
  54.     cont[x]=0;
  55.     }
  56.     do
  57.     {
  58.         for (x=0; x
  59.         {
  60.             if (cont[x]==0)
  61.             {
  62.             number=x+1;
  63.             cout<<"\n\n\n\n\n\n"<<<" is now at position "<<<".\n";    // tell players their position and snake and ladders' location
  64.             cout<<"Ladders (4, 9, 19, 21, 28, 51, 71. 80)\n";
  65.             cout<<"Snakes  (17, 54, 62, 64, 87, 93, 96, 98)\n\n";
  66.             srand(time(0));            // seeds the random sequence generated by rand() later

  67.             do                         // a do-while loop to ensure that the choice entered by users is either t or q
  68.             {

  69.             cout<<"ress 'T' to throw a dice!\nPress 'Q' to quit game.\n";
  70.             cin>>dice;
  71.             if (toupper(dice) !='Q' && toupper(dice) !='T')     // toupper is used so that it is exercuate without
  72.                                                                // considering the upper and lower case of the choice
  73.             {
  74.             Line();                   // funciton call
  75.             cout<<"\nINVALID CHOICE.\n\n";
  76.             Line();                   // funciton call
  77.             }
  78.             }
  79.             while (toupper(dice)!='Q'&& toupper(dice)!='T');
  80.             if (toupper(dice)=='Q')
  81.             {
  82.             cout<<"\n\n\n"<<<" had quit the game.";           // exits from the loop when user key in 'q' or 'Q'
  83.             cont[x]=1;
  84.             cin.get();
  85.             cin.get();
  86.             break;
  87.             }
  88.             else if (toupper(dice)=='T')
  89.             {
  90.                 A=(rand()%6)+1;     // randomly generate a number from 1 to 6
  91.                  if (A==1)
  92.                 cout<<"\n   \n . \n   \n\n\n"<<<" gets 1!!\n";   // displays to tell users the number on the 'dice'
  93.                 else if (A==2)
  94.                  cout<<"\n . \n   \n . \n\n\n"<<<" gets 2!!\n";
  95.                 else if (A==3)
  96.                 cout<<"\n.  \n . \n  .\n\n\n"<<<" gets 3!!\n";
  97.                 else if (A==4)
  98.                 cout<<"\n. .\n   \n. .\n\n\n"<<<" gets 4!!\n";
  99.                 else if (A==5)
  100.                 cout<<"\n. .\n . \n. .\n\n\n"<<<" gets 5!!\n";
  101.                 else if (A==6)
  102.                 cout<<"\n. .\n. .\n. .\n\n\n"<<<" gets 6!!\n";
  103.                 player[x]+=A;

  104.                 if( player[x] > 100 )     // when users' position is over 100, user will reverse to their respective position
  105.                 {
  106.                 reverse = player[x]-100;
  107.                 wall();           // funciton call
  108.                 cin.get();
  109.                 cout<<" "<<<" had reached "<<<"!\n\n";
  110.                 cin.get();
  111.                 player[x] = 100 - ( player[x] - 100 );
  112.                 cout<<" Ops!! "<<<" knocks the wall!\nPlayer "<<<" will reverse "<<<" steps......\n\n";
  113.                 wall();           // funciton call
  114.                 cout<<""<<<" is now at position "<<<"!\n\n";
  115.                 cin.get();

  116.                 }

  117.                 switch (player[x])   // place the location of snakes and ladders
  118.                 {
  119.                 case 4:
  120.                 Ladder(name[x]);     // funciton call
  121.                 player[x]=14;
  122.                   break;
  123.                      case 9:
  124.                       Ladder(name[x]);     // funciton call
  125.                 player[x]=31;
  126.                 break;
  127.                   case 19:
  128.                   Ladder(name[x]);    // funciton call
  129.                   player[x]=38;
  130.                 break;
  131.                    case 21:
  132.                     Ladder(name[x]);    // funciton call
  133.                 player[x]=42;
  134.                  break;
  135.                     case 28:
  136.                  Ladder(name[x]);    // funciton call
  137.                  player[x]=84;
  138.                 break;
  139.                     case 51:
  140.                     Ladder(name[x]);    // funciton call
  141.                    player[x]=67;
  142.                 break;
  143.                     case 71:
  144.                  Ladder(name[x]);    // funciton call
  145.                   player[x]=91;
  146.                 break;
  147.                   case 80:
  148.                   Ladder(name[x]);   // funciton call
  149.                   player[x]=100;
  150.                 break;
  151.                   case 17:
  152.                   Snake(name[x]);    // funciton call
  153.                   player[x]=7;
  154.                 break;
  155.                   case 62:
  156.                   Snake(name[x]);     // funciton call
  157.                   player[x]=19;
  158.                 break;
  159.                   case 54:
  160.                   Snake(name[x]);     // funciton call
  161.                   player[x]=34;
  162.                 break;
  163.                   case 64:
  164.                   Snake(name[x]);     // funciton call
  165.                   player[x]=60;
  166.                 break;
  167.                   case 87:
  168.                   Snake(name[x]);     // funciton call
  169.                    player[x]=24;
  170.                 break;
  171.                  case 93:
  172.                  Snake(name[x]);      // funciton call
  173.                    player[x]=73;
  174.                 break;
  175.                   case 95:
  176.                   Snake(name[x]);      // funciton call
  177.                   player[x]=75;
  178.                 break;
  179.                  case 98:
  180.                   Snake(name[x]);     // funciton call
  181.                   player[x]=79;
  182.                 break;
  183.                   }
  184.                 cin.get();
  185.               cout<<""<<name[x]<<" had reached "<<player[x]<<"!\n\n";    // displays usres' position
  186.                 cin.get();
  187.                }
  188.             if (player[x]==100)                      // exits loops when one of the players reach 100
  189.             {
  190.             winner (number, name[x]);
  191.             break;
  192.             }
  193.            next=x+1;
  194.            if (next>=n)
  195.            next=0;
  196.            cout<<"\n\n\n\n"<<<"'s turn!!!\n\n\n\n\n\n";
  197.         }
  198.         }

  199.   }
  200. while(player[x]!=100);                 // keep the looping untill a player reach 100
  201. }                                  // end of main funciton


  202. // functions definition


  203. void Line()
  204. {
  205. cout<<"-------------------------------------------------------------------------------\n";
  206. }

  207. void Ladder(char name[])
  208. {
  209. cin.get();
  210. cout<<"\n\nHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH_LADDER_HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH\n\n";
  211. cout<<"\nLook!! There is a ladder over there!\n";
  212. cin.get();
  213. cout<<""<<<" climb up the ladder.\n";
  214. }

  215. void Snake(char name[])
  216. {
  217. cin.get();
  218. cout<<"\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~SNAKE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n";
  219. cout<<"\nWoot!! "<<<" meets an anaconda!!!!\n";
  220. cin.get();
  221. cout<<"In order to escape from the snake,"<<<" had run away.\n";
  222. }

  223. void wall()
  224. {
  225. cout<<"\n\n`````````````````````````````````WALL``````````````````````````````````````````\n\n";
  226. }

  227. void winner(int number,char name[] )
  228. {
  229. cin.get();
  230. cout<<"\n\n----------------------------------WINNER---------------------------------------\n";
  231. cout << "\nPlayer  [" <<< "] - "<<<" win!!!!\n\nCongratulation!!!\n\n"<
  232. cout<<"----------------------------------WINNER---------------------------------------\n";
  233. }

  234. // end of functions definition
复制代码


[ 本帖最后由 Wongkokchoy 于 11-10-2008 01:19 PM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 11-10-2008 05:57 PM | 显示全部楼层
还没有人来帮我吗。。。。。。
回复

使用道具 举报

发表于 11-10-2008 08:05 PM | 显示全部楼层

回复 144# Wongkokchoy 的帖子

只要加入一个 quit flag, 然后设定若 quit_flag == true, 就 skip, 否则继续

没法些个sample了, 这几天都要考试,很忙。 看看其他的大大能不能帮你吧
回复

使用道具 举报

 楼主| 发表于 11-10-2008 09:07 PM | 显示全部楼层
我想不到要怎样link next跟cont[x], 这个解决的话, 就完了
回复

使用道具 举报

Follow Us
发表于 12-10-2008 08:51 PM | 显示全部楼层
刚才花了些时间来做一个,
因为你的code 太长乐,
要修改有点复杂。
而且可以减少case 的应用。
贴出来参考参考,分享分享。
有错请给意见。

用BC++
  1. #include <iostream>
  2. #include <conio>
  3. #include <math.h>
  4. #include <time.h>
  5. #include <stdlib.h>


  6. int check (int a);
  7. int calc_step(int player , int step)
  8.         {
  9.       int score = player + step;
  10.       if (score ==100)
  11.          return score;
  12.       else if (score<100)
  13.          player+=step;
  14.       else if (score>100)
  15.          {
  16.          cout <<"Over ladder ... reverse !!! "<<endl;
  17.          player = 200-score;
  18.          }
  19.       return check(player); //call 下面的function 来检查是否升降。
  20.    }

  21. int check (int a)
  22.    {
  23.       int step[]={4, 9, 19, 21, 28, 51, 71,80 , 17, 54, 62, 64, 87, 93, 96, 98}; //代表升和降的位置,可以自己修改
  24.       int goTo[]={14,31,38,42,84,67,91,100 ,7,34,19,60,24,73,75,79}; //应对上面的位置所变换到的位置

  25.       for(int i=0 ; i <16 ; i++)
  26.               if (a==step[i])
  27.            {
  28.             cout <<"******caution********* From "<<step[i]<<" goto "<<goTo[i]<<endl;
  29.                    return goTo[i] ;
  30.            }
  31.       return a; //如果没有升降,就return 原本的。这个return 会return 给calc_step ,然后calc_step return 回去main. 两个都要int , 因为这样你不用call 第二次function来检查是否升降。
  32.    }

  33. int main(){
  34.    int num;
  35.    int count=0;
  36.    bool win = false; //看是否输赢。
  37.    int step;
  38.    int winner ;
  39.         cout <<"lease enter the number of player"<<endl;
  40.    cin >>num;
  41.    int * player = new int[num];
  42.         char* name = new char [num];
  43.    name = new char[20];
  44.    for (int i=0; i < num; i++)
  45.      {
  46.       player[i]=0; //将所有分数置0
  47.       name[i]=(i+80); // 因为只是测试版本,所以名字随便放
  48.      }
  49.    cout <<"press 't' to throw , 'q' to quit"<<endl;
  50.    do{
  51.    for(int i=0; i<num ; i++)
  52.      {
  53.       cout <<"player["<<(i+1)<<"] : name = "<<name<<" , score = "<< player[i]<<endl;

  54.       if(getch()=='q') //getch() 相当于你的cin.get()
  55.               return 0; //exit

  56.       srand(time(0));
  57.       step=(rand()%6)+1;
  58.       cout <<"The dice is "<<step<<endl;  //直接可以print出来不用用switch
  59.       player[i] = calc_step(player[i] , step);
  60.       if (player[i]==100)
  61.               {        
  62.                  win= true;
  63.                  winner = i;
  64.               }
  65.       cout <<"player["<<(i+1)<<"] : name = "<<name<<" , score = "<< player[i]<<endl<<endl;

  66.      }
  67.    }while(!win); //看是否输赢。
  68.    cout <<"The winner is player["<<winner<<"] : , name : "<<name[winner];
  69.    getch();
  70.    return 0;
  71.    }
复制代码

[ 本帖最后由 ss_sky87 于 12-10-2008 09:13 PM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 12-10-2008 09:40 PM | 显示全部楼层
flow chart 已经画了,所以就算了吧。。。。

不过想问一下,C++ 能不能放图片作background?
回复

使用道具 举报


ADVERTISEMENT

发表于 12-10-2008 10:09 PM | 显示全部楼层

回复 143# Wongkokchoy 的帖子

呵呵, 可以重新贴过吗你的code。 上面那个有很多error噢。 无法帮你查看。
回复

使用道具 举报

 楼主| 发表于 12-10-2008 10:21 PM | 显示全部楼层
  1. #include <iostream.h>        
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <time.h>
  5. #include <ctype.h>

  6. void Line();                     
  7. void Ladder(char[]);
  8. void Snake(char[]);
  9. void wall();
  10. void winner(int, char[]);

  11. void main()
  12. {
  13.     char dice, **name;                                      
  14.     int A, n, number, x, reverse, *player, *cont;
  15.     Line();                                       
  16.    
  17.     cout<<"\t\tWelcome to Snake and Ladder Game!!\n\n";           
  18.     cout<<"Introduction: if a player reach a point where there is a ladder, he/she will \nraise to a higher location.\n";
  19.     cout<<"\nOn the other hand, if the player reach a spot where there is a snake over there,the player will drop to a lower location.\n\n";
  20.     cout<<"The 1st player who reach 100 first will be the WINNER!!!!!!\n";
  21.     Line();                                       

  22.     do                                               
  23.     {
  24.     cout<<"\nPlease enter the numbers of players:\n";
  25.     cin>>n;
  26.     cin.get();
  27.     if (n<=0)
  28.     cout<<"INVALID number of player!\n";
  29.     }
  30.     while (n<=0);
  31.     player=new int [n];           
  32.     name=new char* [n];
  33.     cont=new int [n];
  34.     for(int i = 0; i < n ;i++)
  35.     name = new char[100];
  36.     for (int x=0; x<n; x++)
  37.     {
  38.     cout<<"lease enter player "<<(x+1)<<"'s name.\n";   

  39.     cin.getline (name[x], 100);
  40.     }
  41.     for (int x=0; x<n; x++)
  42.     {
  43.     cout<<"layer "<<(x+1)<<"'s name is "<<name[x]<<".\n";
  44.     }
  45.     cout<<"\nSo there will be "<<n<<" player(s) in the game.\n";
  46.     cout<<"There are ladders at 4, 9, 19, 21, 28, 51, 71. 80 \n(80 will directly send you to the vitory!!)\n";
  47.     cout<<"Snakes located at 17, 54, 62, 64, 87, 93, 96, 98.\n\n";
  48.     cout<<"(All players start at 0)\n\n\n";
  49.     cout<<"Good Luck and Have Fun!!!\n\n";
  50.     Line();                     
  51.     for (x = 0; x < n; x++)   
  52.     {
  53.     player[x] = 0;
  54.     cont[x]=0;
  55.     }
  56.     do
  57.     {
  58.         for (x=0; x<n; x++)   
  59.         {
  60.             if (cont[x]==0)
  61.             {
  62.             number=x+1;
  63.             cout<<"\n\n\n\n\n\n"<<name[x]<<" is now at position "<<player[x]<<".\n";   
  64.             cout<<"Ladders (4, 9, 19, 21, 28, 51, 71. 80)\n";
  65.             cout<<"Snakes  (17, 54, 62, 64, 87, 93, 96, 98)\n\n";
  66.             srand(time(0));         

  67.             do                     
  68.             {

  69.             cout<<"ress 'T' to throw a dice!\nPress 'Q' to quit game.\n";
  70.             cin>>dice;
  71.             if (toupper(dice) !='Q' && toupper(dice) !='T')     
  72.                                                             
  73.             {
  74.             Line();                 
  75.             cout<<"\nINVALID CHOICE.\n\n";
  76.             Line();                   // funciton call
  77.             }
  78.             }
  79.             while (toupper(dice)!='Q'&& toupper(dice)!='T');
  80.             if (toupper(dice)=='Q')
  81.             {
  82.             cout<<"\n\n\n"<<name[x]<<" had quit the game.";         
  83.             cont[x]=1;
  84.             cin.get();
  85.             cin.get();
  86.             break;
  87.             }
  88.             else if (toupper(dice)=='T')
  89.             {
  90.                 A=(rand()%6)+1;    \
  91.                  if (A==1)
  92.                 cout<<"\n   \n . \n   \n\n\n"<<name[x]<<" gets 1!!\n";   
  93.                 else if (A==2)
  94.                  cout<<"\n . \n   \n . \n\n\n"<<name[x]<<" gets 2!!\n";
  95.                 else if (A==3)
  96.                 cout<<"\n.  \n . \n  .\n\n\n"<<name[x]<<" gets 3!!\n";
  97.                 else if (A==4)
  98.                 cout<<"\n. .\n   \n. .\n\n\n"<<name[x]<<" gets 4!!\n";
  99.                 else if (A==5)
  100.                 cout<<"\n. .\n . \n. .\n\n\n"<<name[x]<<" gets 5!!\n";
  101.                 else if (A==6)
  102.                 cout<<"\n. .\n. .\n. .\n\n\n"<<name[x]<<" gets 6!!\n";
  103.                 player[x]+=A;

  104.                 if( player[x] > 100 )     
  105.                 {
  106.                 reverse = player[x]-100;
  107.                 wall();           // funciton call
  108.                 cin.get();
  109.                 cout<<" "<<name[x]<<" had reached "<<player[x]<<"!\n\n";
  110.                 cin.get();
  111.                 player[x] = 100 - ( player[x] - 100 );
  112.                 cout<<"Ops!! "<<name[x]<<" knocks the wall!\n"<<name[x]<<" will reverse "<<reverse<<" steps......\n\n";
  113.                 wall();           // funciton call
  114.                 cout<<""<<name[x]<<" is now at position "<<player[x]<<"!\n\n";
  115.                 cin.get();

  116.                 }

  117.                 switch (player[x])   
  118.                 {
  119.                 case 4:
  120.                 Ladder(name[x]);     
  121.                 player[x]=14;
  122.                   break;
  123.                      case 9:
  124.                       Ladder(name[x]);   
  125.                 player[x]=31;
  126.                 break;
  127.                   case 19:
  128.                   Ladder(name[x]);   
  129.                   player[x]=38;
  130.                 break;
  131.                    case 21:
  132.                     Ladder(name[x]);    // funciton call
  133.                 player[x]=42;
  134.                  break;
  135.                     case 28:
  136.                  Ladder(name[x]);   
  137.                  player[x]=84;
  138.                 break;
  139.                     case 51:
  140.                     Ladder(name[x]);  
  141.                    player[x]=67;
  142.                 break;
  143.                     case 71:
  144.                  Ladder(name[x]);   
  145.                   player[x]=91;
  146.                 break;
  147.                   case 80:
  148.                   Ladder(name[x]);   
  149.                   player[x]=100;
  150.                 break;
  151.                   case 17:
  152.                   Snake(name[x]);   
  153.                   player[x]=7;
  154.                 break;
  155.                   case 62:
  156.                   Snake(name[x]);   
  157.                   player[x]=19;
  158.                 break;
  159.                   case 54:
  160.                   Snake(name[x]);   
  161.                   player[x]=34;
  162.                 break;
  163.                   case 64:
  164.                   Snake(name[x]);     
  165.                   player[x]=60;
  166.                 break;
  167.                   case 87:
  168.                   Snake(name[x]);     
  169.                    player[x]=24;
  170.                 break;
  171.                  case 93:
  172.                  Snake(name[x]);   
  173.                    player[x]=73;
  174.                 break;
  175.                   case 95:
  176.                   Snake(name[x]);   
  177.                   player[x]=75;
  178.                 break;
  179.                  case 98:
  180.                   Snake(name[x]);     
  181.                   player[x]=79;
  182.                 break;
  183.                   }
  184.                 cin.get();
  185.                 cout<<""<<name[x]<<" had reached "<<player[x]<<"!\n\n";   
  186.                 cin.get();
  187.                }
  188.             if (player[x]==100)                     
  189.             {
  190.             winner (number, name[x]);
  191.             break;
  192.             }
  193.           }
  194.            cout<<"\n\n\n\nNext player!!!\n\n\n\n\n\n";
  195.         
  196.         }

  197.   }
  198. while(player[x]!=100);                 
  199. }                          




  200. void Line()
  201. {
  202. cout<<"-------------------------------------------------------------------------------\n";
  203. }

  204. void Ladder(char name[])
  205. {
  206. cin.get();
  207. cout<<"\n\nHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH_LADDER_HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH\n\n";
  208. cout<<"\nLook!! There is a ladder over there!\n";
  209. cin.get();
  210. cout<<""<<name<<" climbs up the ladder.\n";
  211. }

  212. void Snake(char name[])
  213. {
  214. cin.get();
  215. cout<<"\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~SNAKE~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n";
  216. cout<<"\nWoot!! "<<name<<" meets an anaconda!!!!\n";
  217. cin.get();
  218. cout<<"In order to escape from the snake,"<<name<<" had run away.\n";
  219. }

  220. void wall()
  221. {
  222. cout<<"\n\n`````````````````````````````````WALL``````````````````````````````````````````\n\n";
  223. }

  224. void winner(int x,char name[] )
  225. {
  226. cin.get();

  227. cout << "\nPlayer  ["<<(x+1)<<"] - "<<name<<" win!!!!\n\nCongratulation!!!\n\n"<<endl;

  228. }
复制代码


[ 本帖最后由 Wongkokchoy 于 12-10-2008 10:45 PM 编辑 ]
回复

使用道具 举报

发表于 12-10-2008 11:26 PM | 显示全部楼层

回复 150# Wongkokchoy 的帖子

感觉上好像没什么问题除了第一个玩家赢利就跳出来外。
回复

使用道具 举报

 楼主| 发表于 13-10-2008 12:06 AM | 显示全部楼层
对啊,已经没问题了,只是一个player赢了,就停了。

现在只是想改进罢了。 队友问能不能够把整个board放进去C++。所以就来问问看咯。。。

[ 本帖最后由 Wongkokchoy 于 13-10-2008 12:08 AM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 14-10-2008 05:42 PM | 显示全部楼层
再来一个, 如果user在 no. of player 那边 enter 1.2, 我的program就变成了 一个player, 那个player叫做2

有没有办法来check user enter的是不是整数?
回复

使用道具 举报

发表于 15-10-2008 01:19 AM | 显示全部楼层
原帖由 Wongkokchoy 于 14-10-2008 05:42 PM 发表
再来一个, 如果user在 no. of player 那边 enter 1.2, 我的program就变成了 一个player, 那个player叫做2

有没有办法来check user enter的是不是整数?


只想到if((x-ceil(x)) <0)

[ 本帖最后由 lliioonn 于 15-10-2008 01:32 AM 编辑 ]
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 23-12-2025 09:16 AM , Processed in 0.123457 second(s), 21 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表