我正在对UVa在线法官进行练习(https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=2899&mosmsg=Submission+received+with+ID+22762175)。我的代码在计算机上可以正常工作,但是当我提交代码时,它会向我报告运行时错误。我究竟做错了什么? 这是我的代码:
#include <iostream>
using namespace std;
int t;
int n = 50;
int speed;
int main(int argc, char ** argv) {
std::cin >> t;
int data[t][n] = {0};
for (int i = 0; i < t; i++) {
std::cin >> n;
data[i][0] = n;
for (int j = 1; j <= n; j++) {
std::cin >> data[i][j];
}
}
for (int i = 0; i < t; i++) {
speed = 0;
for (int j = 1; j <= data[i][0]; j++) {
if (data[i][j] > speed) {
speed = data[i][j];
}
}
std::cout << "Case " << i+1 << ": " << speed << endl;
}
return 0;
}
谢谢。