Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
92913 | 胡海峰老师 | 初级冒泡排序 | C++ | Accepted | 4 MS | 208 KB | 480 | 2024-10-06 23:17:25 |
/*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 main() { int n; 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; } } for(int i=1;i<=n-1;i++) printf("%d ",a[i]); printf("%d",a[n]); return 0; }