解题思路:
注意事项:
参考代码:
Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a[] = new int [n]; int count=0; for (int i=0;i<n;i++){ a[i]=sc.nextInt(); } for (int i=0;i<n;i++){ for (int j=i+1;j<n;j++){ if (a[i]>a[j]){ int temp=a[i]; a[i]=a[j]; a[j]=temp; count+=(j-i)*2; } } } System.out.println(count);
0.0分
0 人评分
wu-理财计划 (C++代码)浏览:832 |
WU-printf基础练习2 (C++代码)浏览:2002 |
剪刀石头布 (C语言代码)浏览:752 |
三角形 (C语言代码)浏览:905 |
1050题解(结构体数组与结构体指针的使用)浏览:1107 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:509 |
Quadratic Equation (C语言代码)浏览:988 |
C语言程序设计教程(第三版)课后习题12.5 (C语言代码)浏览:764 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:527 |
整除的尾数 (C语言代码)浏览:811 |