Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
84759 | 揭伟琦 | 打印每一趟冒泡排序 | C++ | Accepted | 1 MS | 276 KB | 401 | 2024-07-16 11:51:12 |
#include<iostream> using namespace std; int a[2001]; int main(){ int n,t; cin>>n; for(int i=0;i<n;i++){ cin >>a[i]; } for(int i=0;i<n-1;i++){ for(int j=0;j<n-1-i;j++){ if(a[j]>a[j+1]){ t=a[j]; a[j]=a[j+1]; a[j+1]=t; } } for(int k=0;k<n;k++){ cout <<a[k]<<' '; } cout <<endl; } return 0; }