TOPIC

presentation error

Lucas Santos asked 2 years ago

#include <iostream>
#include <cstring>
#include <stdio.h>
using namespace std;
int main() {
    char oculta[100],resultado[100];
    int testes,cont,cont2,aux=0,tam;
    cin >> testes;
    getchar();
    for(cont=0;cont<testes;cont++){
      fgets(oculta,100,stdin);
      tam = strlen(oculta);
        for(cont2=0;cont2 < tam;cont2++){
            if(cont2 == 0 and oculta[0] != ' '){
                    resultado[aux]=oculta[0];
                    aux++;
            }
            if(oculta[cont2-1] == ' ' and oculta[cont2] != ' '){
                    resultado[aux]=oculta[cont2];
                    aux++;
                }
            }
        resultado[aux] = '\0';
        //cout << resultado << endl;
        printf("%s\n",resultado);
        aux = 0;
    }
}

anyone? :/

This topic has not been answered yet. Be the first!

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