#6980: WA=_= WHY??????求解


yan88663319 (L)


#include<iostream>
#include<cmath>
using namespace std;

int main()
{
     int x=9;
     int total;
     bool no=0;
     int a[x][x];
     while (true)
     {
          total = 0;
          no = 0;
          /* 開始儲存9 * 9陣列的值 */
          for (int i = 0; i < x; i++)
          {
              for (int j = 0; j < x; j++)
              {
                  
                  if (cin >> a[i][j])
                  {
                    ;
                  }
                  else
                  {
                        goto END;
                  }                     
              }
          }
          //judje(1)------------------------
          for (int i = 0; i < x; i++)
          {
              for (int j = 0; j < x; j++)
              {
                  total+=a[i][j];                    
              }
          }
          if(total!=45)
          {
                no=1;
          }
          total=0;
          //judje(2)------------------------
          for (int i = 0; i < x; i++)
          {
              for (int j = 0; j < x; j++)
              {
                  total+=a[j][i];                    
              }
          }
          if(total!=45)
          {
                no=1;
          }
          total=0;
          //judje方塊------------------------
          for (int i = 0; i < 9; i+=3)
          {
              for (int j = 0; j < 9; j+=3)
              {
                    for (int k = i; k < i+3; k++)
                    {
                         for (int l =j; l <j+3; l++)
                         {
                               total+=a[k][l]; 
                         }
                     }

                   
              }
          }
          
          if(total!=45)
          {
                no=1;
          }
          total=0;
          //cout no/yes---------------------
          if(no!=0)
          {
            cout<<"no"<<endl;
          }
          else
          {
            cout<<"yes"<<endl;  
          }
        }
END:                
          
          
    return 0;
}

#6984: Re:WA=_= WHY??????求解


passerr (20130326 0340 48)


你可以看看該討論串[不懂為什麼會 WA 少一行]a313031所說的
#6994: Re:WA=_= WHY??????求解


yan88663319 (L)


你可以看看該討論串[不懂為什麼會 WA 少一行]a313031所說的


我自己找到了

只是因為判定45的式子

要擺在第一個FOR內

第二個FOR下對(搥胸)