//a016: 數獨(SUDOKU)
#include<iostream>
#include<cstdlib>
using namespace std;
char sort(char a[9]){
int i,j,temp,count;
char num[9]={'1','2','3','4','5','6','7','8','9'};
for(i=0;i<9;i++){
for(j=0;j<9;j++){
a[j]<a[j-1]?
temp=a[j],
a[j]=a[j-1],
a[j-1]=temp
:
a[j]=a[j];
}
}
for(i=0,count=0;i<9;i++){
if(a[i]==num[i]){
count++;
}
}
return (count==9)?0:1;
}
main(){
int i,j,k,m,n,count;
char a[9][9],b[9];
restart:
//存入輸入之數字
while(cin>>a[0][0]){
for(i=0;i<9;i++){
for(j=0;j<9;j++){
if(i==0&&j==0)
continue;
cin>>a[i][j];
}
}
//橫的檢測
for(i=0;i<9;i++){
for(j=0;j<9;j++){
b[j]=a[i][j];
}
if(sort(b)==1){
cout<<"no"<<endl;
goto restart;
}
}
//直的檢測
for(j=0;j<9;j++){
for(i=0;i<9;i++){
b[i]=a[i][j];
}
if(sort(b)==1){
cout<<"no"<<endl;
goto restart;
}
}
//9宮格檢測
for(i=0;i<=6;i+=3){
for(m=0;m<=6;m+=3){
for(j=m,count=0;j<m+3;j++){
for(k=i;k<i+3;k++){
b[count]=a[j][k];
count++;
}
}
if(sort(b)==1){
cout<<"no"<<endl;
goto restart;
}
}
}
cout<<"yes"<<endl;
}
return 0;
}
與正確輸出不相符(line:2)
您的答案為: no
正確答案為: yes
************************************
想請教各位高手大大
我在自己的電腦跑都OK
為什麼還是一直WA?
還有
我想知道WA中那個line:2是代表什麼阿@@?
一直WA...
想請各位高手幫忙><