解题思路:
利用标记数组
注意事项:
明确端点是否包含其中
参考代码:
#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语言代码)浏览:1555 |
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)浏览:1709 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:551 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:594 |
【数组的距离】 (C语言代码)浏览:728 |
printf基础练习2 (有点不明白)浏览:836 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:511 |
C二级辅导-等差数列 (C语言代码)浏览:694 |
剪刀石头布 (C语言代码)浏览:1432 |
C语言程序设计教程(第三版)课后习题12.2 (C语言代码)浏览:753 |