C语言求助大佬们,感觉和题解一样,找不出问题

P1219 [USACO1.5] 八皇后 Checker Challenge

su180 @ 2023-11-08 14:37:50

#include<stdio.h>
#include<string.h>
int n,i,j,count=0;
int a[20],b[20],c[20],d[20];

void print(int count)
{
    if(count<=2){
        for(i=1;i<=n;i++){
            printf("%d",a[i]);
        }
        printf("\n");
    }
    count++;
}

void def(int i)
{
    if(i>n){
        void print();
        return; 
    }else{
        for(j=1;j<=n;j++){
            if(b[j]==0&&c[j-i+n]==0&&d[i+j]==0){
                a[i]=j;
                b[j]=1;
                c[j-i+n]=1;
                d[i+j]=1;
                def(i+1);
                b[j]=0;
                c[j-i+n]=0;
                d[i+j]=0;
            }
        }
    }
}

int main()
{
    scanf("%d",&n);
    def(1);
    printf("%d\n",count);
    return 0;
}

球球了QAQ


by Mr学霸君 @ 2023-11-08 14:48:24

数组开大


by su180 @ 2023-11-09 08:51:20

@Mr学霸君 大佬,我开到100、1000都不对 QAQ


|