TOPIC

Erro de compilação, alguem pode ajudar

Adriano Mourao asked 2 years ago

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

int main(){

    int M=1,N=1,soma;
    char ta[1000];

    while(true){

    scanf("%i %i",&M,&N);

    if(1<=M<=N<=999999999){
        if(M!=0 && N!=0){
            soma = M+N;
            sprintf(ta, "%i", soma);
            for(int x=0;x<strlen(ta);x++){
                if(ta[x]=='0'){
                    for(int x2=x;x2<strlen(ta);x2++){
                        ta[x2] = ta[x2+1];
                    }
                    x--;
                }
            }
            printf("%s\n",ta);
        }
        else{
            break;
        }       
    }

}
 return 0;  
}

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

  • feodorv replied 2 years ago

    Hm.

    if(1<=M<=N<=999999999)

    it's wrong construction. Moreover you do not need to check the input values. If the problems states that

    1 <= M && M <= N && N <= 999999999

    then you can trust this statement.