-
Notifications
You must be signed in to change notification settings - Fork 148
/
Test36.java
20 lines (18 loc) · 1002 Bytes
/
Test36.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package com.so;
import org.junit.Test;
/**
* 第36题
* 数组中的两个数字如果前面一个数字大于后面一个数字,
* 则这两个数字组成一个逆序对,输入一个数组,求逆序对的总数
*
* @author qgl
* @date 2019/03/22
*/
public class Test36 {
@Test
public void test36() throws Exception {
int[] array = {1, 2, 3, 4, 5, 6, 7, 0};
int[] array2 = {364, 637, 341, 406, 747, 995, 234, 971, 571, 219, 993, 407, 416, 366, 315, 301, 601, 650, 418, 355, 460, 505, 360, 965, 516, 648, 727, 667, 465, 849, 455, 181, 486, 149, 588, 233, 144, 174, 557, 67, 746, 550, 474, 162, 268, 142, 463, 221, 882, 576, 604, 739, 288, 569, 256, 936, 275, 401, 497, 82, 935, 983, 583, 523, 697, 478, 147, 795, 380, 973, 958, 115, 773, 870, 259, 655, 446, 863, 735, 784, 3, 671, 433, 630, 425, 930, 64, 266, 235, 187, 284, 665, 874, 80, 45, 848, 38, 811, 267, 575};
System.out.println("逆序对总数:" + InversePairs36.inversePairs(array));
}
}