#include<stdio.h>
#include<stdlib.h>
void main(){
int i, j, b, a[10]; printf("随机猜想数为:\n");
for(i = 0; i < 10; i++){
a[i] = rand();
printf("%d\n",a[i]);
}
printf("按升序排列为:\n");
for(i = 0; i < 9; i++){
for(j = 0; j < 9 - i ; j++){
if(a[j] > a[j + 1]){
b = a[j];
a[j] = a[j + 1];
a[j + 1] = b;
}
}
}
for(i = 0; i < 10; i++){
printf("%d\n",a[i]);
}
}
时间: 2024-10-13 13:26:31