import java.util.*;
import static java.lang.System.*;
public class main{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int cases = sc.nextInt();
for(int t = 0; t < cases; t++)
{
int n = sc.nextInt();
int[] datas = new int[n];
for(int i = 0; i < n; i++)
datas[i] = sc.nextInt();
int count = 0;
for(int i = 0; i < n-1; i++)
for(int j = 0; j < n-1; j++)
{
if(datas[j] > datas[j+1])
{
int temp = datas[j+1];
datas[j+1] = datas[j];
datas[j] = temp;
count++;
}
}
System.out.printf("Optimal train swapping takes %d swaps.\r\n", count);
}
}
};
留言
張貼留言