解题思路:
注意事项:
参考代码:
#include<iostream>
#include<algorithm>
using namespace std;
struct Node
{
int start,end;
}p[1005];
bool cmp(Node a,Node b){return a.end < b.end;}//升序
int main()
{
int n; cin >> n;
int count = 1;
for(int i = 0; i < n; i++)
{
cin >> p[i].start >> p[i].end;
}
sort(p, p + n, cmp);
int temp = p[0].end;
for(int j = 1; j < n; j++)
{
if(p[j].start >= temp)
{
temp = p[j].end;
count++;
}
}
cout << count;
return 0;
}
0.0分
1 人评分
倒杨辉三角形 (C语言代码)浏览:3892 |
矩阵乘法 (C++代码)浏览:1454 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:539 |
【计算两点间的距离】 (C语言代码)浏览:879 |
ASCII帮了大忙浏览:748 |
剪刀石头布 (C语言代码)浏览:1747 |
【绝对值排序】 (C语言代码)浏览:820 |
C语言训练-亲密数 (C语言代码)浏览:682 |
杨辉三角 (C语言代码)浏览:484 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:401 |