Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
69107 周奕辰 打印每一趟冒泡排序 C++ Wrong Answer 1 MS 272 KB 489 2024-03-30 14:59:28

Tests(0/3):


Code:

#include<iostream> #include<algorithm> using namespace std; int main(){ int n; cin >> n; int a[n]; for(int i=0;i<n;i++) { cin >> a[i]; } for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { if(a[i]<a[j]) { swap(a[i],a[j]); cout << a[i] << " "; } } } for(int i=0;i<n;i++) { cout << a[i] << " "; } return 0; }


Run Info:

------Input------
5 5 4 3 2 1
------Answer-----
4 3 2 1 5 3 2 1 4 5 2 1 3 4 5 1 2 3 4 5
------Your output-----
5 4 3 2 1