请问哪里出问题了,全是wrong

P1428 小鱼比可爱

```cpp #include <stdio.h> int main() { int n = 0; int j, i = 0; scanf("%d", &n); int arr[105] = {0}; for (int j = 0; j < n; j++) { scanf("%d", &arr[j]); } int arr2[105] = {0}; for (i = 0; i < n; i++) { int count = 0; for (j = 0; j < i; j++) { if (arr[j] < arr[i]) count++; } arr2[i] = count; } for (j = 0; j < n; j++) { printf("%d ", arr2[j]); } return 0; } ```
by quchenming @ 2023-09-28 08:15:44


原因是你的数组没定义大小。其实你这个用法我没怎么用过,但是题目给数据范围了,还是定义一下大小吧
by quchenming @ 2023-09-28 08:17:04


```cpp #include<bits/stdc++.h> using namespace std; const int MAX = 1000; int a[MAX]; int main(){ int n; cin>>n; for(int i=0;i<n;i++) cin>>a[i]; cout<<0<<' '; for(int i=1;i<n;i++){ int tot = 0; for(int k=i;k>=0;k--) if(a[i] > a[k]) tot++; cout<<tot<<' '; } } ```
by cinemaaa @ 2023-09-28 08:59:46


数组没有定义范围
by cinemaaa @ 2023-09-28 09:00:45


@[quchenming](/user/363995) 感谢
by Patrick_xuan @ 2023-09-30 20:09:59


@[cinemaaa](/user/1008115) 感谢
by Patrick_xuan @ 2023-09-30 20:10:31


|