//《算法》P103
1 template <typename Type> 2 void greedySelector(int n, Type s[], Type f[], bool A[]) 3 { 4 A[1] = true; 5 int j = 1; 6 for(int i = 2; i <= n; ++ i){ 7 if(f[j] <= s[i]){ 8 A[i] = true; 9 j = i; 10 } 11 else 12 A[i] = false;
13 } 14 }
//《算法》P103
1 template <typename Type> 2 void greedySelector(int n, Type s[], Type f[], bool A[]) 3 { 4 A[1] = true; 5 int j = 1; 6 for(int i = 2; i <= n; ++ i){ 7 if(f[j] <= s[i]){ 8 A[i] = true; 9 j = i; 10 } 11 else 12 A[i] = false;
13 } 14 }