新手小白,CE求调

P1219 [USACO1.5] 八皇后 Checker Challenge

zengbinhuan @ 2024-10-04 18:59:00

#include <bits/stdc++.h>
using namespace std;
int a[100], b[100], c[100], d[100], tot, n;
int print (){
    if (tot < 3){
        for (int i = 1; i <= n; i ++)
        cout << a[i] << " ";
        cout << endl;
        }
        tot ++;
}
void search(int k) {
    if (n < k){
        print ();
        return ;
    }
    else{
        for (int i = 1; i <= n; i ++){
            if((!b[i]) && (!c[k + i]) && (!d[k - i + n])){
                a[k] = i;
                b[i] = 1;
                c[k + i] = 1;
                d[k - i + n] = 1;
                search (k + 1);
                b[i] = 0;
                c[k + i] = 0;
                d[k - i + n] = 0;
            }
        }
    }
}
signed mian() {
    cin >> n;
    search (1);
    cout << tot;
    return 0;
}

by 114514xxx @ 2024-10-04 19:00:13

mian

by Texas_the_Omertosa @ 2024-10-04 19:00:28

又有 mian 吃了好耶


by Texas_the_Omertosa @ 2024-10-04 19:00:51

int print 还不返回值


by ZHANGGUIZHI @ 2024-10-04 19:01:02

mian

by Texas_the_Omertosa @ 2024-10-04 19:01:09

@zengbinhuan


by Blikewsr @ 2024-10-04 19:01:10

Good mian


by Hagasei @ 2024-10-04 19:01:43

@zengbinhuan print 应该设成 void,然后 main 写成 mian 了。


by 114514xxx @ 2024-10-04 19:03:15

此贴终


by litangzheng @ 2024-10-04 19:03:15

@zengbinhuan int类型的函数需要一个返回值,而且你的函数使用以及定义后面为什么隔了一个空格才传参数。


by zengbinhuan @ 2024-10-04 19:03:59

@Hagasei谢谢大佬,膜拜,sno


|