编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#1755 #993. 汉诺塔问题 Compile Error 0 0 ms 0 K C / 242 B t330026101 2023-10-15 16:47:53
显示原始代码

#include <stdio.h>

int main() {
    int n, m;
    scanf("%d", &n);
    if (n = 1) {
        m = 1
    } else if (n = 2) {
        m = 3
    } else if (n = 3) {
        m = 7
    } else if (n = 4) {
        m = 15
    } else {
        m = 29 printf("%d", m);
        return 0;
    }

    /*1
    2
    3
    4
    5*/

编译信息

/sandbox/1/a.c:8:7: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
        if (n=1){
            ~^~
/sandbox/1/a.c:8:7: note: place parentheses around the assignment to silence this warning
        if (n=1){
             ^
            (  )
/sandbox/1/a.c:8:7: note: use '==' to turn this assignment into an equality comparison
        if (n=1){
             ^
             ==
/sandbox/1/a.c:9:6: error: expected ';' after expression
                m=1}
                   ^
                   ;
/sandbox/1/a.c:10:12: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
        else if (n=2){
                 ~^~
/sandbox/1/a.c:10:12: note: place parentheses around the assignment to silence this warning
        else if (n=2){
                  ^
                 (  )
/sandbox/1/a.c:10:12: note: use '==' to turn this assignment into an equality comparison
        else if (n=2){
                  ^
                  ==
/sandbox/1/a.c:11:6: error: expected ';' after expression
                m=3}
                   ^
                   ;
/sandbox/1/a.c:12:12: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
        else if (n=3){
                 ~^~
/sandbox/1/a.c:12:12: note: place parentheses around the assignment to silence this warning
        else if (n=3){
                  ^
                 (  )
/sandbox/1/a.c:12:12: note: use '==' to turn this assignment into an equality comparison
        else if (n=3){
                  ^
                  ==
/sandbox/1/a.c:13:6: error: expected ';' after expression
                m=7}
                   ^
                   ;
/sandbox/1/a.c:14:12: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
        else if (n=4){
                 ~^~
/sandbox/1/a.c:14:12: note: place parentheses around the assignment to silence this warning
        else if (n=4){
                  ^
                 (  )
/sandbox/1/a.c:14:12: note: use '==' to turn this assignment into an equality comparison
        else if (n=4){
                  ^
                  ==
/sandbox/1/a.c:15:7: error: expected ';' after expression
                m=15}
                    ^
                    ;
/sandbox/1/a.c:17:7: error: expected ';' after expression
                m=29
                    ^
                    ;
/sandbox/1/a.c:28:2: error: expected '}'
        
        ^
/sandbox/1/a.c:5:1: note: to match this '{'
{
^
4 warnings and 6 errors generated.