解题思路:
注意事项:
参考代码:
#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语言代码)浏览:855 |
最长单词 (C语言代码)浏览:1362 |
A+B for Input-Output Practice (VI) (C语言代码)浏览:552 |
字符逆序 (C语言代码)浏览:612 |
交换Easy (C语言代码)浏览:759 |
简单的a+b (C语言代码)浏览:460 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:548 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:546 |
母牛的故事 (C语言代码)浏览:478 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:521 |