Jump to content

Converter programa para Python


Regiane

Recommended Posts

vocês conhecem algum conversor da linguagem c para Python? sei que são bem semelhantes, porém não estou compreendendo como fazer alterações para transforma-lo. por favor, se alguém conseguir me ajudar, eu agradeço 💕

#include <iostream> 
#include <string.h> 
int main (){
    int i;
    char telefone[20];
    char ch;
    i=0
    while((ch=getchar ())) 1='\n') (
        if (ch=='-')telefone[1]='-';
        else if (ch >=48 && ch <=57) telefone [i]=ch;
        else if (ch >=65 && ch <=67) telefone [i]='2';
        else if (ch >=68 && ch <=70) telefone [i]='3';
        else if (ch >=71 && ch <=73) telefone [i]='4';
        else if (ch >=74 && ch <=76) telefone [i]='5';
        else if (ch >=77 && ch <=79) telefone [i]='6';
        else if (ch >=80 && ch <=83) telefone [i]='7';
        else if (ch >=84 && ch <=86) telefone [i]='8';
        else if (ch >=87 && ch <=90) telefone [i]='9';
        
        i++;
    }
    telefone[i]='\0';
    printf("%s", telefone);
    return(0);
}
 
Link to comment
Share on other sites

7 minutos atrás, iron disse:

Tens aqui a solução:

https://www.portugal-a-programar.pt/forums/topic/79145-como-esse-programa-ficaria-em-python/?tab=comments#comment-623605

 

Lê bem os comentários que a solução está lá 😉

oi, eu vi esse post tb e infelizmente tá em inglês o livro de python, vocês poderiam me ajudar?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.