TOPIC

WA 100% mas deu certo em todos os testes

PHILIP MAHAMA AKPANYI asked 3 years ago

#include <stdio.h>
#include <string.h>

int main(){
    int num;

    scanf("%d", &num); //Test case

    do{
        setbuf(stdin, NULL);
        char word[1000] = " ";

        //Taking string including spaces
        scanf("%[^\n]s", word);

        char * chk;
        chk = " ";

        chk = strtok (word," "); //Function to separate the string
        while (chk != NULL){
            if(strcmp(chk, " ") == 0){
                printf(" ");
            }
            else{
                printf ("%c",chk[0]);
            }

            chk = strtok (NULL, " ");
        }

        printf("\n");
    num--;
    }while(num > 0);

    return 0;
}

Any help is welcome... Qualquer ajuda é bem vindo

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

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