|
|
вернуться в форумWorks good for my local, why it returns a wrong result? #include <iostream> using namespace std; int main() { double n, k1, k2, k3, pos = 2, current_pos = 2, oldsum = 0; cin >> n; cin >> k1 >> k2; while (cin >> k3) { double sum = k1 + k2 + k3; if (sum > oldsum) { oldsum = sum; pos = current_pos; } k1 = k2; k2 = k3; ++current_pos; } cout << oldsum << " " << pos; return 0; } |
|
|