#include
int a[100];
void bubble(int n) //冒泡排序n个元素
{int i,j,t;
#include
void bubbleSort(int array[], int length);
int main() {
int array[20], length, i, j;
int tmp;
for (i = 0; ; ++i) {
scanf("%d", &tmp);
if (tmp < 0) {
break;
}
array[i] = tmp;
}
length = i;
//(1)
putchar('\n');
bubbleSort(array, length);
for (i = 0; i < length; ++i) {
printf("%d ", array[i]);
}
putchar('\n');
//(2)
putchar('\n');
scanf("%d", &tmp);
for (i = 0; i < length; ++i) {
if(array[i] < tmp) {
break;
}
}
for (j = length; j > i; --j) {
array[j] = array[j-1];
}
array[i] = tmp;
++length;
for (i = 0; i < length; ++i) {
printf("%d ", array[i]);
}
putchar('\n');
//(3)
putchar('\n');
for (i = 0; i <= length/2; ++i) {
tmp = array[i];
array[i] = array[length-1-i];
array[length-1-i] = tmp;
}
for (i = 0; i < length; ++i) {
printf("%d ", array[i]);
}
putchar('\n');
return 0;
}
void bubbleSort(int array[], int length) {
int i, j, tmp;
for (i = 0; i < length-1; ++i) {
for (j = 0; j < length-1-i; ++j) {
if (array[j] < array[j+1]) {
tmp = array[j];
array[j] = array[j+1];
array[j+1] = tmp;
}
}
}
}
算了,不帮助你啦!!!