#include<iostream>
#include<stdlib.h>
using namespace std;
int main() {
cout << "输入数组长度:";
int length = 0;
cin >> length;
cout << endl;
cout << "输入数组:";
int *A = new int[100];
for (int i = 0; i < length; i++)
{
cin >> A[i];
}
int *B = new int[100];
for (int i = 0; i < length; i++)
{
B[i] = 0;
}
int *C = new int[100];
cout << endl;
cout << "数据采集完毕" << endl;
for (int i = 0; i < length-1; i++)
{
for (int j = i+1; j < length; j++)
{
if (A[i] > A[j]) {
B[i] += 1;
}else {
B[j] += 1;
}
}
cout << "第" << i + 1 << "次:";
for (int j = 0; j < length; j++)
{
cout << B[j]<<" ";
}
cout << endl;
}
for (int i = 0; i < length; i++)
{
C[B[i]] = A[i];
}
cout << "排序后:";
for (int i = 0; i < length; i++)
{
cout << C[i] << " ";
}
cout << endl;
}
01-20
05-10
216
08-05
988
06-18
1439