啊啊啊 为什么会超时???

ykj99 2024-04-19 20:48:03 23

#include <bits/stdc++.h>

using namespace std; int a[1001]; int main() { int n, sum = 0; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; sum += a[i]; } cout << sum << endl;

for (int i = n; i >= 1; i--) {
    cout << a[i] << " ";
}
cout << endl;

int max = a[1], maxi = 1;
for (int i = 2; i <= n; i++) {
    if (a[i] > max) {
        max = a[i];
        maxi = i;
    }
}
cout << max << " " << maxi;
cout << endl;

int min = a[1], mini = 1;
for (int i = 2; i <= n; i++) {
    if (a[i] <= min) {
        min = a[i];
        mini = i;
    }
}
cout << min << " " << mini;

int ans = 0;
for (int i = 1; i <= n; i++) {
    if (a[i] > 10 && a[i] < 100)
        ans++;
}
cout << ans << " ";
for (int i = 1; i <= n; i++) {
    if (a[i] > 10 && a[i < 100])
        cout << a[i] << " ";
}
cout << endl;

int x, y;
cin >> x >> y;
for (int i = n; i >= x; i--) a[i + 1] = a[i];
a[x] = y;
for (int i = 1; i <= n + 1; i++) cout << a[i] << endl;

int k;
for (int i = k; i <= n; k++) a[i] = a[i + 1];
for (int i = 1; i <= n; i++) cout << a[i] << " ";
return 0;

}

{{ vote && vote.total.up }}

共 4 条回复

CPP 刷题王

🐶

CPP 刷题王

不保证AC哟(

root 站长

@CPP 👍

CPP 刷题王
int k;
for (int i = k; i <= n; k++) a[i] = a[i + 1];
  1. 你的 没有值。
  2. k++ 应该为 i++