Run ID:92915

提交时间:2024-10-06 23:25:48

/*Input 10 5 3 2 4 1 6 10 8 9 7 Output 10 9 8 7 6 5 4 3 2 1*/ #include <stdio.h> int a[2005] ={}; int n; void printRes() { //printf("%d--------\n",n); for(int i=1;i<=n-1;i++) printf("%d ",a[i]); printf("%d\n",a[n]); } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=1;i<n;i++) { for(int j=1 ;j<=n-i;j++) { if(a[j]>a[j+1]) { int tmp = a[j]; a[j] = a[j+1]; a[j+1] = tmp; } } printRes(); } return 0; }