Sicily-sorting algorithm
这题我又是直接调用sort偷了个懒
1 #include<iostream> 2 #include<string> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 int main() { 7 int m,n; 8 while(cin >> m >> n && m!= 0 && n!=0) { 9 int a[100000] = {0}; 10 for (int i = 0; i < m; i++) { 11 cin >> a[i]; 12 } 13 sort(a, a+m); 14 cout << a[0]; 15 for (int i = n; i < m; i+=n) { 16 cout << " " << a[i]; 17 } 18 cout << endl; 19 } 20 return 0; 21 }
-