才上三天基础课,写这个好难...不过还是有成就感的,求打赏啊~.~
#include<stdio.h>
int main(){
int arr[5]={6,3,5,9,7};
int i = 0;
int j = 0;
int temp = 0;
while (i < 5) {
printf("%d\t",arr[i]);
i++;
}
printf("\n");
i = 0;
while (i < 4) {
while (j < 4) {
if (arr[j]>arr[j+1]) {
temp = arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
j++;
}
i++;
}
i = 0;
while (i < 5) {
printf("%d\t",arr[i]);
i++;
}
return 0;
} |
|