题解 | 左侧严格小于计数

左侧严格小于计数

https://www.nowcoder.com/practice/c5922c6cdd1445749bd42f586c422435

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        int res = 0;
        int[] arr = new int[num];
        for (int i = 0; i < num; i++ ) {
            arr[i] = in.nextInt();
            for (int j = 0; j < i; j++) {
                if (arr[j] < arr[i]) res++;
            }
            System.out.printf("%d ", res);
            res = 0;
        }
    }
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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