TOPIC

5% wrong answer

Eduardo Balistieri asked 2 years ago

include

using namespace std;

int main(){

char palavra[100];

for(int i = 0; i < 100; i++){ scanf("%c", &palavra[i]); if(palavra[i] == '\n') break; }

for(int i = 0; i < 100; i++){ if(palavra[i] == '\n') break;

if(palavra[i] == ','){
printf("\n");
continue;
}
printf("%c", palavra[i]);

} printf("\n");

return 0; }

This topic was solved and cannot recieve new replies.

  • Eduardo Balistieri replied 2 years ago

    I changed the "100" by "101" and still the message 5% wrong answer. Some idea?

  • Eduardo Balistieri replied 2 years ago

    Ok, the 128 works, strange because the "aditionals" characters are \n and \0, so 102 must be working. Thanks for help

  • feodorv replied 2 years ago

    And '\0' can be a character number 102. Why you are so humble? Why not 128 as a buffer size? Why not fgets() instead of scanf("%c", ...)?

  • feodorv replied 2 years ago

    char palavra[100];

    Couldn't you try to increase your buffer size? '\n' can be a character number 101 ...