0
Guys, my code is giving 5% error and I can’t find a why, it’s the question of the minefield:
#include <iostream>
using namespace std;
int main(){
int N, i;
int qtbombas;
cin >> N;
int tabuleiro[N];
for(i = 0; i < N; i++){
cin>>tabuleiro[i];
}//inserir bombas no tabuleiro
for(i = 0; i < N; i++){/*calcular e printar a quantidade de bombas nos arredores*/
if (i == 0)
qtbombas = tabuleiro[i]+tabuleiro[i+1];
else if (i == N-1)
qtbombas = tabuleiro[i]+tabuleiro[i-1];
else
qtbombas = tabuleiro[i]+tabuleiro[i-1]+tabuleiro[i+1];
cout<<qtbombas<<endl;
}
return 0;
}
Link to the question: https://www.urionlinejudge.com.br/judge/pt/problems/view/2399
What should the code do? What is it doing? What are the tested inputs? What were the outputs produced? What were the expected outputs?
– Woss
@Andersoncarloswoss The statement, example of entries and the rest is on the link: https://www.urionlinejudge.com.br/judge/pt/problems/view/2399
– Victor Stafusa
Your code seems correct, although it could have been better. I can’t see where the error is. URI gave you some error message or reason why something went wrong?
– Victor Stafusa