Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
45963 zhouhuanyu 玙静 排序 C++ 通过 0 MS 252 KB 322 2024-04-21 15:32:27

Tests(1/1):


#include <bits/stdc++.h> using namespace std; int a[10001]; int main(){ int n, cnt = 0; cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 1; i <= n; i++){ if(a[i] > a[i + 1]){ int k = a[i]; a[i] = a[i + 1]; a[i + 1] = k; cnt++; } } cout << cnt - 1; return 0; }


测评信息: