Read post
程序没错,但是一直wrong answer,难道格式有问题??
#include<stdio.h>
void init_arr(int arr[6])
{
int i;
for(i=0;i<6;i++)
arr[i] = -100;
}
int is_in_arr(int n,int arr[6])
{
int i;
for(i=0;i<6;i++)
if(n == arr[i])
return 1;
return 0;
}
int main()
{
int flag = 0;
int cl[6],diag45[6],diag135[6];
int i,j,n,num;
scanf("%d",&n);
for(i= 0;i<n;i++)
{
flag = 0;
init_arr(cl);
init_arr(diag45);
init_arr(diag135);
for(j=0;j<6;j++)
{
scanf("%d",&num);
if(is_in_arr(num,cl) || is_in_arr((j-num),diag45) || is_in_arr((j+num),diag135))
{
flag = 1;
break;
}
else
{
cl[j] = num;
diag45[j] = j - num;
diag135[j] = j + num;
}
}
if(flag)
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
Reply
|