70264 - CSP-J第一轮同测模拟卷1-阅读程序1
统计题目(材料题)
01 #include <iostream>
02 using namespace std;
03
04 int n;
05 int a[1010];
06
07 int main() {
08 cin >> n;
09 for (int i = 1; i <= n; i++) {
10 cin >> a[i];
11 }
12 int ans = 0;
13 for (int i = 1; i <= n; i++) {
14 for (int j = i + 1; j <= n; j++) {
15 if (a[i] > a[j]) {
16 ans++;
17 }
18 }
19 }
20 cout << ans << endl;
21 return 0;
22 }
||

关注我们