| 21746 | 2026-01-13 18:59:26 | mikloshunor | Zenehallgatás | cpp17 | Compilation error |
#include <iostream>
#include <vector>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> x
vector <int> hossz(n);
for (int i = 0; i < n; i++)
{
cin >> hossz[i];
}
for (int i = 1; i < n; i++)
{
hossz [i] += hossz[i - 1];
}
int x, maradek;
for (int i = 0; i < k; i++)
{
cin >> x;
maradek =x % hossz[n - 1];
if (maradek == 0)
{
cout << n << " ";
}
else
{
cout << lower_bound(hossz.begin(), hossz.end(), maradek) - hossz.begin() + 1 << " ";
}
}
return 0;
}
open /var/local/lib/isolate/426/box/a.out: no such file or directory
main.cpp: In function 'int main()':
main.cpp:10:17: error: 'x' was not declared in this scope
10 | cin >> n >> x
| ^
main.cpp:14:16: error: 'hossz' was not declared in this scope
14 | cin >> hossz[i];
| ^~~~~
main.cpp:18:9: error: 'hossz' was not declared in this scope
18 | hossz [i] += hossz[i - 1];
| ^~~~~
main.cpp:24:22: error: 'hossz' was not declared in this scope
24 | maradek =x % hossz[n - 1];
| ^~~~~