TOPIC

Presentation error

mrncandido asked 5 years ago

#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    long long N, M, p, s;
    cin >> N;
    long long fila[N];
    for(int i=1; i<=N; i++){
        fila[i]=0;
    }
    for(int i=1; i<=N; i++){
        cin >> p;
        fila[i]=p;
    }
    cin >> M;
    for(int i=1; i<=M; i++){
        cin >> s;
        for(int i=1; i<=N; i++){
            if(fila[i]==s){
                fila[i]=0;
            }
        }
    }
    for(int i=1; i<=N; i++){
        if(fila[i]!=0){
            if(i<N){
                cout << fila[i] << " ";
            } else {
                cout << fila[i];
            }
        }
    }
    cout << endl;
}

Remember not post solutions. Your post may be reviewed by our moderators.

  • dliksn replied 4 years ago

    É preciso inserir uma nova linha ao final ou um "\n" no último elemento da fila

  • feodorv replied 5 years ago

    If fila[N] is zero then you do not process line #31 and the output line remains with the ending space.