大佬们,为什么过不了
查看原帖
大佬们,为什么过不了
743057
nomophobia楼主2023/1/15 21:47
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>

using namespace std;

const int N = 10090;
int q[N];

int main()
{   
    int n = 0;
    cin >> n;
    for (int i = 0; i < n; i++) 
    {
        cin >> q[i];
    }
    int note = 0;
    for (int i = 1; i <= n - 1; i++)
    {
        for (int j = i; j <= n; j++) 
        {
            if (q[i] > q[j]) 
            {
                swap(q[i], q[j]);
                note++;
            }
        }
    }

    cout << note;
    return 0;
}
2023/1/15 21:47
加载中...