萌新求助(^人^)

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

silver_wing6 @ 2023-05-13 15:06:59

为什么标记被砍的树用不了啊

#include<bits/stdc++.h>
using namespace std;
int main(){
    int l,z,m;
    z=0;
    cin>>l>>m;
    int a[l];
    memset(a,0,sizeof(a));
    for(int i=1;i<=m;i++){
        int head,tail;
        cin>>head>>tail;
        for(int j=head;j<=tail;j++){
            a[j]=1;
        }
    }           
    for (int k=0;k<=l;k++){
        if (a[k]=0){
            z++;
        }else z=z+0;
    }
    cout<<z;
    return 0;
}

by __pig__ @ 2023-05-13 15:12:41

if (a[k]==0)

by __pig__ @ 2023-05-13 15:13:33

@silver_wing6


by silver_wing6 @ 2023-05-13 15:18:41

@oier01 谢谢大佬


by silver_wing6 @ 2023-05-13 15:19:29

@oier01 找了一天硬是没找出来555 是我眼瞎了


|