MW6776 @ 2022-09-27 00:56:01
#include <stdio.h>
int main(){
int l,m,u,v,cnt;
scanf("%d %d",&l,&m);
int a[l];
for(int n=0;n<=l;n++){
a[n]=0;
}
for(int i=1;i<=m;i++){
scanf("%d %d",&u,&v);
for(int j=u;j<=v;j++){
a[j]=1;
}
}
for(int k=0;k<=l;k++){
if(a[k]==0){
cnt++;
}
}
printf("%d",cnt);
return 0;
}
by 编码落寞 @ 2022-09-27 08:33:14
@MW6776
局部变量cnt赋值初值0
by MW6776 @ 2022-09-27 11:14:20
@编码落寞 okok,可以了,谢谢大佬帮忙