编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#1811 #993. 汉诺塔问题 Compile Error 0 0 ms 0 K C / 297 B t330026038 2023-10-15 16:53:46
显示原始代码
#include <stdio.h>
void hanoi(int n, char A, char B, char C);
{
    if (n == 1) {
        printf("%c%c ", A, C);
    } else {
        hanoi(n - 1, A, C, B);
        printf("%c%c ", A, C);
        hanoi(n - 1, B, A, C);
    }
    return;
}
int main() {
    int e;
    scanf("%d", &e);
    printf(e, 'A', 'B', 'C');
    return 0;
}

编译信息

/sandbox/1/a.c:3:1: error: expected identifier or '('
{
^
/sandbox/1/a.c:20:10: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'const char *' [-Wint-conversion]
        printf (e,'A','B','C');
                ^
/usr/include/stdio.h:332:43: note: passing argument to parameter '__format' here
extern int printf (const char *__restrict __format, ...);
                                          ^
1 warning and 1 error generated.