编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#3529 #1006. 超级强迫症 Compile Error 0 0 ms 0 K C / 511 B s230026068 2023-11-25 15:34:08
显示原始代码
#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 *lengh = (int *)malloc(n * sizeof(int));
    for (int i = 0; i < n; i++) scanf("%d", &length[i]);

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

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

    free(lengh);
    return 0;
}

编译信息

/sandbox/1/a.c:9:27: error: use of undeclared identifier 'n'
        int *lengh= (int*)malloc(n*sizeof(int));
                                 ^
/sandbox/1/a.c:10:17: error: use of undeclared identifier 'n'
        for(int i=0; i<n;i++)
                       ^
/sandbox/1/a.c:11:17: error: use of undeclared identifier 'length'; did you mean 'lengh'?
           scanf("%d",&length[i]);
                       ^~~~~~
                       lengh
/sandbox/1/a.c:9:7: note: 'lengh' declared here
        int *lengh= (int*)malloc(n*sizeof(int));
             ^
/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:14: error: use of undeclared identifier 'n'
        for(int=1;i<n;i++){
                    ^
/sandbox/1/a.c:14:16: error: use of undeclared identifier 'i'
        for(int=1;i<n;i++){
                      ^
/sandbox/1/a.c:15:6: error: use of undeclared identifier 'length'; did you mean 'lengh'?
                if(length[i]!=length[i+1]){
                   ^~~~~~
                   lengh
/sandbox/1/a.c:9:7: note: 'lengh' declared here
        int *lengh= (int*)malloc(n*sizeof(int));
             ^
/sandbox/1/a.c:15:13: error: use of undeclared identifier 'i'
                if(length[i]!=length[i+1]){
                          ^
/sandbox/1/a.c:15:17: error: use of undeclared identifier 'length'; did you mean 'lengh'?
                if(length[i]!=length[i+1]){
                              ^~~~~~
                              lengh
/sandbox/1/a.c:9:7: note: 'lengh' declared here
        int *lengh= (int*)malloc(n*sizeof(int));
             ^
/sandbox/1/a.c:15:24: error: use of undeclared identifier 'i'
                if(length[i]!=length[i+1]){
                                     ^
/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){
               ^
               ==
1 warning and 12 errors generated.