贪吃算法
#include <iostream>
#include <algorithm>
using namespace std;
struct Lu
{
int x;
int y;
};Lu Hui[100];
int main()
{
int n;
while (cin >> n && n)
{
int j = 0;
int Yi = 1;
for (int i = 0; i < n; i++)
cin >> Hui[i].x >> Hui[i].y;
for (int i = 0; i < n; i++)
for (int x = i; x < n; x++)
if (Hui[i].y > Hui[x].y)
swap(Hui[i], Hui[x]);
for (int i = 1; i < n; i++)
if (Hui[i].x >= Hui[j].y)
{
Yi++;
j = i;
}
cout << Yi << endl;
}
return 0;
}