求助编译错误

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

@[chenxinhao0402](/user/799227) for后面有分号
by zgy_123 @ 2023-02-01 08:35:48


@[chenxinhao0402](/user/799227) 1. memset需要加cstring头文件 2. 后面循环改为 ``` for(int i=0;i<=1;i++) if(tree[i]==0)s++; ```
by Misophiliac @ 2023-02-01 08:36:24


![](https://cdn.luogu.com.cn/upload/image_hosting/vdc0n41i.png) 不行啊,全WA了
by chenxinhao0402 @ 2023-02-01 08:43:14


请问lz的l,m输入了吗
by hzoi_Shadow @ 2023-02-01 08:44:29


int后面跟了啊
by chenxinhao0402 @ 2023-02-01 08:46:37


@[chenxinhao0402](/user/799227) 最后一个循环是到l吧
by Misophiliac @ 2023-02-01 08:49:11


@[The_Shadow_Dragon](/user/848964)
by chenxinhao0402 @ 2023-02-01 08:49:31


@[chenxinhao0402](/user/799227) 你只是定义,没有输入
by hzoi_Shadow @ 2023-02-01 08:50:03


for(int i=0;i<=1,i++); if(tree[i]==0)s++; printf("%d",s); return 0; 这样?
by chenxinhao0402 @ 2023-02-01 08:51:09


``` #include<cstdio> #include<cstring> using namespace std; int main() { int l,m,tree[10010]={0},a,b,s=0; scanf("%d%d",&l,&m); memset(tree,0,sizeof(tree)); for (int i=0;i<m;i++) { scanf("%d%d",&a,&b); for(int j=a;j<=b; j++) tree[j]=1; } for(int i=0;i<=1;i++) if(tree[i]==0)s++; printf("%d",s); return 0; } ``` 采纳
by chenxinhao0402 @ 2023-02-01 08:54:04


| 下一页