注册 登录
编程论坛 C++教室

一个可编译无法运行的程序,请教????????????????

houenxun 发布于 2008-03-21 16:13, 699 次点击
#include <iostream.h>
int iShudoNum=0;
class Shudo{
private:
    int iRow;
    int iList;
    int iId;
    int iData[9][9];
public:
    Shudo()
    {
        iShudoNum++;
        iRow=9;
        iList=9;
        for(int i=0;i<9;i++)
            for(int j=0;j<9;j++)
                cin>>iData[i][j];
        iId=iShudoNum;
        cout<<"The number"<<iId<<"shudo has been created";

    }

    ~Shudo()
    {
        cout<<"The "<<iId<<"has been reclaimed!"<<endl;

    }
    bool judge()
    {
         for(int i=0;i<9;i++)
            for(int j=0;i<j;j++)
                for(int k=j+1;k<9;k++)
                    if(iData[i][j]==iData[i][k]||iData[j][i]==iData[k][i])
                        return false;
        return true;
    }
    void output()
    {
        for(int i=0;i<9;i++)
            for(int j=0;j<9;j++)
            {
                cout<<iData[i][j];
                if (j==8)
                    cout<<endl;
            }
    }
};
void main()
{
    bool judgement;
    Shudo myShudo;
    judgement=myShudo.judge();
    if (judgement==true)
        myShudo.output();
    else
        cout<<"The shudo has not been created creactly!"<<endl;

}
4 回复
#2
afraidhlq2008-03-21 17:56
可以运行,你的构造函数要输入81个数据却没提示。。。。
#3
zjl1382008-03-21 18:03
你用什么编译器,麻烦贴错误提示!
还有你看什么书啊,怎么你写这种风格的化码!
#4
Luckly_Boy2008-03-21 18:35
可以运行
但,你这东西不叫数独
你值判断了横行和竖行,而且就连这部分for语句也有问题,并不能实现你想要的效果
#5
Luckly_Boy2008-03-21 18:40
for(int i=0;i<9;i++)
            for(int j=0;i<j;j++)
                for(int k=j+1;k<9;k++)
这样一改,就可以实现横行,竖行的判断了
1