编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#3539 #1006. 超级强迫症 Compile Error 0 0 ms 0 K C / 483 B s230026068 2023-11-25 15:36:21
显示原始代码
#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) {
    int N;
    scanf("%d", &N);
    int length[N] for (int i = 0; i < N; i++) scanf("%d", &length[i]);

    int flag = 1;
    for (int = 1; i < N; i++) {
        if (length[i] != length[0]) {
            flag = 0;
            break;
        }
    }

    if (flag = 1) {
        printf("Yes\n");
    } else
        printf("No\n");

    free(length);
    return 0;
}

编译信息

/sandbox/1/a.c:9:15: error: expected ';' at end of declaration
        int length[N]
                     ^
                     ;
/sandbox/1/a.c:14:9: error: expected identifier or '('
        for(int=1;i<N;i++){
               ^
/sandbox/1/a.c:14:12: error: expected ';' in 'for' statement specifier
        for(int=1;i<N;i++){
                  ^
/sandbox/1/a.c:14:12: error: use of undeclared identifier 'i'
/sandbox/1/a.c:14:16: error: use of undeclared identifier 'i'
        for(int=1;i<N;i++){
                      ^
/sandbox/1/a.c:15:13: error: use of undeclared identifier 'i'
                if(length[i]!=length[0]){
                          ^
/sandbox/1/a.c:21:9: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
        if(flag=1){
           ~~~~^~
/sandbox/1/a.c:21:9: note: place parentheses around the assignment to silence this warning
        if(flag=1){
               ^
           (     )
/sandbox/1/a.c:21:9: note: use '==' to turn this assignment into an equality comparison
        if(flag=1){
               ^
               ==
/sandbox/1/a.c:26:9: warning: attempt to call free on non-heap object 'length' [-Wfree-nonheap-object]
          free(length);
               ^
2 warnings and 6 errors generated.