| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 999 人关注过本帖
标题:五子棋游戏的判断输赢不知道哪里有问题
只看楼主 加入收藏
btn
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2021-1-30
结帖率:50%
收藏
已结贴  问题点数:10 回复次数:1 
五子棋游戏的判断输赢不知道哪里有问题
[code]#include<iostream>
#include<cstring>
using namespace std;


int main(){
    cout<<"---Game of Chess---"<<endl;
    cout<<"H against the C"<<endl;
   
    char a[7][7];
    for(int i=0;i<7;i++){
        for(int j=0;j<7;j++)
            a[i][j]='*';
    }
        for(int i=0;i<7;i++){
            for(int j=0;j<7;j++)
               cout<<a[i][j]<<' ';
            cout<<endl;
        }
   
    cout<<"Enter X,Y coordinates for moving:";
   
    int times=1;
    bool win(int x,int y,char a[7][7]);
   
   int m,n;
    do{
      cin>>m>>n;
   
      if(times%2!=0)
      a[m-1][n-1]='H';
      else
      a[m-1][n-1]='C';
   
       for(int i=0;i<7;i++){
            for(int j=0;j<7;j++){
               cout<<a[i][j]<<' ';
           }
            cout<<endl;
        }
    cout<<"Enter X,Y coordinates for moving:";
    times++;
    }while(win);
   
   
    if(times%2==0)
    cout<<"C won!";
    else
    cout<<"H won!";
   
    return 0;
}
bool win(int x,int y,char a[7][7]){
   
    for(int i=0;i<7;i++){
        int count=0;
            for(int j=0;j<6;j++){
                if(a[i][j]=a[i][j+1])
                count++;
            }
            if(count=4)
            return false;
            else
            return true;
    }
        for(int i=0;i<6;i++){
           int count=0;
           for(int j=0;j<7;j++){
               
                if(a[i][j]=a[i+1][j])
                count++;
            }
            if(count=4)
            return false;
            else
            return true;
        }
        for(int i=0;i<6;i++){
           int count=0;
           for(int j=0;j<6;j++){
               
                if(a[i][j]=a[i+1][j+1])
                count++;
            }
            if(count=4)
            return false;
            else
            return true;
       }
           for(int i=0;2<i&&i<7;i++){
             int count=0;
             for(int j=0;2<i&&i<7;j++){
               
                if(a[i][j]=a[i-1][j-1])
                count++;
            }
            if(count=4)
            return false;
            else
            return true;
           }
}



判断输赢不知道哪里出了问题
搜索更多相关主题的帖子: cout for return int count 
2021-03-04 16:23
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:10 
你的判断逻辑没说,那我不知道。
我仅仅编译了一下你的代码,有很多错误

    bool win(int x,int y,char a[7][7]);

    do{
        ……
    }while(win);


有四处 if(count=4)
2021-03-08 10:52
快速回复:五子棋游戏的判断输赢不知道哪里有问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017538 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved