int is_safe(int i,int j) { int k = 1; int num = i;
i--;
while (i = !0)
{
if (board[i][j] == 1) return 0;
i--;
}
i = (num-1);
while (i = !0 && j+k <= size)
{
if (board[i][j + k] == 1) return 0;
k++;
i--;
}
i = (num-1);
k = 1;
while (i = !0 && j-k >0)
{
if (board[i][j - k] == 1) return 0;
k++;
i--;
}
return 1;
}
Finding n-Queen. I made it, but I can't debug it. 프로그래 I think the program keeps running<
c
while (I : zero!).
where !0 is 1 (! is NOT operator)
1 corresponds to True during True/False, and it is substituted for i.
It's a structure that goes around an infinite loop.
while(i!=0)
You can change it to~
!= operator means 'if not equal'.
© 2024 OneMinuteCode. All rights reserved.