|
|
back to boardtest #5 Posted by Sperow 14 Oct 2020 01:59 I can't find a problem Please, help my code (C++): #include <iostream> #include <string> using namespace std; int main() { int a, b, c, sum, sr, i, n; cin >> n; cin >> a >> b >> c; sum = 0; if (n == 3) { sum = a + b + c; sr = 2; } else { for (i = 3; i < n; i++) { if ((a + b + c) > sum) { sum = a + b + c; sr = i - 1; } a = b; b = c; cin >> c; } } cout << sum<< " "<<sr;
return 0; } |
|
|