题解 | #求逆序数#

求逆序数

https://ac.nowcoder.com/acm/problem/208813


import java.util.Scanner;

public class NC208813 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int []array = new int[n];
        for(int i=0;i<n;i++){
            array[i] = sc.nextInt();
        }
        int count = 0;
        for(int i = 0;i<n;i++){
            for(int j = i;j<n;j++){
                if(array[i]>array[j]) count++;
            }
        }
        System.out.println(count);
    }
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
06-23 18:33
点赞 评论 收藏
分享
北漂的牛马人:211佬,包进的,可能是系统问题
点赞 评论 收藏
分享
星辰再现:裁员给校招生腾地方
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务