|
|
вернуться в форумwhy not? 1 test Wrong answer 1 test #include <iostream> using namespace std; int main() { int n, i, x, max; int mas[1000];
cin >> n; max = 0; for (i = 0; i < n; i++) { cin >> mas[i]; } max = mas[0] + mas[1] + mas[2]; x = 1; for (i = 1; i < n; i++) { if (mas[i] + mas[i + 1] + mas[i + 2] > max) { max = mas[i] + mas[i + 1] + mas[i + 2]; x = i + 1; } } cout << max << ' ' << x + 1 << endl; system("pause"); return (0); } Re: why not? 1 test Because for i = n - 1, mas[i + 1] and mas[i + 2] go out of bounds Re: why not? 1 test Послано Fyodor 10 июн 2019 17:23 put the variables above |
|
|