#include <stdio.h>
int s[11] = {1, 3, 0, 5, 3, 5, 6, 8, 8, 2, 12};
int f[11] = {4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14};
int a[11];
static int select(int s[], int f[], int i, int n);
int main(int argc, char **argv)
{
int i;
select(s, f, 0, 10);
for(i = 0; i < 11; i++){
if(a[i]){
printf("%d ", i+1);
}
}
printf("\n");
return 0;
}
static int select(int s[], int f[], int i, int n)
{
int m;
a[i] = 1;
m = i + 1;
while((m <= n) && (s[m] <= f[i])){
m = m + 1;
}
if(m <= n){
a[m] = 1;
i = m;
select(s, f, m, n);
}
return 0;
}
|