解题思路:
利用标记数组
注意事项:
明确端点是否包含其中
参考代码:
#include <iostream>
using namespace std;
int main ()
{
int l,m;
cin>>l>>m;
int *p=new int [l+1];
for(int i=0;i<l+1;i++)
*(p+i)=1;
for(int i=0;i<m;i++)
{
int temp1,temp2;
cin>>temp1>>temp2;
for(int j=temp1;j<=temp2;j++)
*(p+j)=0;
}
int count=0;
for(int i=0;i<l+1;i++)
if(*(p+i)) count++;
cout<<count<<endl;
return 0;
}
0.0分
0 人评分
C二级辅导-计负均正 (C++代码)浏览:786 |
【C语言训练】排序问题<1> (C语言代码)浏览:479 |
【C语言训练】谁家孩子跑最慢* (C语言代码)浏览:1287 |
C二级辅导-计负均正 (C语言代码)浏览:425 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:478 |
【蟠桃记】 (C语言代码)浏览:516 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:407 |
三角形 (C++代码)递归(存在大量重复计算,容易出现时间超限)浏览:655 |
C语言程序设计教程(第三版)课后习题6.3 (C++代码)浏览:425 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:277 |