ACM Plan UVa - 1260 Sales

Talk is cheap. Show me the code. —— Linus Torvalds

#include <iostream>
#include <cstdio>
using namespace std;
const int MAX = 1010;
int main()
{
    //freopen("i.txt", "r", stdin);
    int t, n, a[MAX], ans = 0;
    scanf("%d", &t);
    while(t--)
    {
        ans = 0;
        scanf("%d", &n);
        for(int i = 0; i < n; i++) scanf("%d", &a[i]);
        for(int i = 1; i < n; i++)
            for(int j = 0; j < i; j++)
                if(a[j] <= a[i]) ans++;
        printf("%d\n", ans);
    }
    return 0;
}
发布了37 篇原创文章 · 获赞 1 · 访问量 1338

猜你喜欢

转载自blog.csdn.net/qq_34727886/article/details/102557118