为啥编译错误???在我自己的编译器上没问题啊??

P1047 [NOIP2005 普及组] 校门外的树

xuanbrother @ 2023-06-25 21:57:35

#include <stdio.h>
int main()
{
    int l,m;
    scanf("%d%d", &l, &m);
    int tree[l+1]={0};
    while(m--)
    {
        int u,v;
        scanf("%d%d", &u, &v);
        for(int i=u-1; i<v; i++)
            tree[i]=1;
    }

    int cnt=0;
    for(int i=0; i<l+1; i++)
        if(!tree[i]) cnt++;

    printf("%d", cnt);

    return 0;
}

by lzg_070506 @ 2023-06-25 22:00:38

数组长度不能用变量


by xuanbrother @ 2023-06-26 04:23:06

@lzg_070506 懂了懂了,感谢!


|