#includeusing namespace std;//希尔排序,步长每次减半void ShellSort(int ndata,int data[]){ int i, j, k; int tmp; for (i = ndata / 2; i > 0; i = i / 2) //步长减半 { for (j = i; j < ndata; j++) { tmp = data[j]; for (k = j; k - i >= 0; k = k - i) { if (data[k - i]>tmp) { data[k] = data[k - i]; } else { break; } } data[k] = tmp; } }}int main(){ int ndata; int data[1000]; cin >> ndata; for (int i = 0; i < ndata; i++) { cin >> data[i]; } ShellSort(ndata, data);// cout << "排序后:" << endl; for (int i = 0; i < ndata; i++) { cout << data[i] << endl; } return 0;}