TOPIC

Runtime Error (EN/PT-Br) or 10% Wrong answer

Murillo Mesmo asked 1 year ago

This one gets Runtime error/ Esse aqui da Runtime Error.

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

int main(){
    char tasem, valor[101]={'\0'};
    int count, icount;
    scanf("%c", &tasem);
    setbuf(stdin, NULL);
    scanf("%s", valor);
    setbuf(stdin, NULL);
    while (tasem!='0' || valor[0]!='0'){
        for(count=0;valor[count] != '\0';count++){
            if (valor[count]==tasem){
                icount=count;
                while (valor[icount]!='\0'){
                    valor[icount]=valor[icount+1];
                    icount++;
                }
                count--;
            }
            if (valor[0]=='\0') break;
        }
        for (icount=0;icount<=count;icount++){
            if (valor[icount]!='0') break;
        }
        if ((icount==strlen(valor)) || (valor[0]=='\0')){
            valor[0]='0'; valor[1]='\0';
        } else{
            for(count=0;count<icount;count++){
                    valor[count]=valor[icount];
                    icount++;
            }
        }
        printf("%s\n", valor);
        setbuf(stdin, NULL);
        scanf("%c", &tasem);
        scanf("%s", valor);
    }
    return 0;
}

This one is at 10% Wrong Answer./Esse fica dando 10% de erro na respostas.

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

int main()
{
    char tasem, valor[101];
    int count, icount;
    scanf("%c", &tasem);
    scanf("%s", valor);
    while (tasem!='0' && valor[0] != '0'){
        for(count=0;valor[count] != '\0';count++){
            if (valor[count]==tasem){
                icount=count;
                while (valor[icount]!='\0'){
                    valor[icount]=valor[icount+1];
                    icount++;
                }
                count--;
            }
            if (valor[0]=='\0') break;
        }
        for (icount=0;icount<=count;icount++){
            if (valor[icount]!='0') break;
        }
        if ((icount==strlen(valor)) || (valor[0]=='\0')) printf("0\n");
        else printf("%s", valor);
        setbuf(stdin, NULL);
        scanf("%c", &tasem);
        scanf("%s", valor);
    }
    printf("\n");
    return 0;
}

Some help?

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

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