解题思路:
利用标记数组
注意事项:
明确端点是否包含其中
参考代码:
#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 人评分
A+B for Input-Output Practice (V) (C语言代码)浏览:442 |
众数问题 (C语言代码)浏览:3510 |
Tom数 (C语言代码)浏览:2010 |
C语言程序设计教程(第三版)课后习题9.8 (C语言代码)浏览:598 |
点我有惊喜!你懂得!浏览:1402 |
C二级辅导-公约公倍 (C语言代码)浏览:2122 |
母牛的故事 (C语言代码)浏览:435 |
C语言训练-排序问题<1> (C语言代码)浏览:599 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:587 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:610 |