站外题目求助:代码运行时错误

题目总版

Albert_Peng @ 2024-11-23 09:00:23

代码大概就是酱紫的:

#include <bits/stdc++.h>
using namespace std;
freopen ("range.in", "r", stdin);
freopen ("range.out", "w", stdout);
int n, k, corpse [10009];
int main () {
    scanf ("%d %d", &n, &k);
    for (int i = 0; i < n; i ++) {
        scanf ("%d", corpse [i]);
        corpse [i] = abs (corpse [i]);
    }
    sort (corpse, corpse + n);
    printf ("%d", corpse [k]);
    return 0;
}

求助!!!


by 0oOo0 @ 2024-11-23 09:03:08

@Albert_Peng 把 freopen 放主函数里。


by Albert_Peng @ 2024-11-23 10:52:38

@0oOo0还是 RTE


|