Continuo ad inviare un codice che in teoria è giusto ma continuo ad ottenere 0/100. Ho provato sia con che senza ifstream ed ofstream ma non cambia nulla. E’ capitato con più problemi e questo è un esempio che ho appena fatto del problema “flea on the number line”.
> #include <iostream>
> #include <fstream>
> #include <vector>
> using namespace std;
>
> int N, passi=0; //salti
> string S; //right or left
>
> int main() {
> ifstream cin("input.txt");
> ofstream cout("output.txt");
>
> cin >> N;
> vector<string> V(N);
>
> for (int i = 0; i < N; i++) {
> cin >> S;
> V[i]=S;
> if (S == "L") {
> passi += 1;
> }
> if (S == "R") {
> passi -= 1;
> }
> }
>
> if (passi < 0) {
> passi *= -1;
> }
>
>
> cout<<passi;
> }