|
|
back to boardWorks good for my local, why it returns a wrong result? Posted by satybal 13 Mar 2024 16:51 #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; } |
|
|