今年暑假不AC
#include<iostream>
using namespace std;
struct tv{
int start, end;
}a[100], b;
void quick_sort(tv s[], int l, int r){
if(l < r){
int i=l, j=r, x=s[l].end;
b = s[l];
while(i < j){
while(i < j && s[j].end >= x) j--;
if(i < j) s[i++] = s[j];
while(i < j && s[i].end < x) i++;
if(i < j) s[j--] = s[i];
}
s[i] = b;
quick_sort(s, l, i-1);
quick_sort(s, i+1, r);
}
}
int result(int select[], int n){
int ans=0;
for(int i=0; i<n; i++)
if(select[i] == 1)
ans++;
return ans;
}
int main(){
int n;
while(cin>>n, n){
int select[100], i, Time = 0;
for(i=0; i<n; i++)
cin>>a[i].start>>a[i].end;
for(i=0; i<n; i++) select[i] = 0;
quick_sort(a, 0, n-1);
i=0;
while(i<n){
if(a[i].start >= Time){
select[i] = 1;
Time = a[i].end;
}
i++;
}
cout<<result(select, n)<<endl;
}
return 0;
}