#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<locale.h>
#include<ctype.h>
#define TRUE 1
#define FALSE 0
#define SENTINELA 0
#define MAX 100
#define MAX_TAM 100
#define MAXNOTA 100
void por_extenso(int numero){
int aux,v_und,v_dez,v_cent,v_mil,v_mil2,v_mil3;
char s_und[MAX_TAM],s_dez[MAX_TAM],s_cent[MAX_TAM],s_mil1[MAX_TAM],s_mil2[MAX_TAM],s_mil3[MAX_TAM];
aux=numero;
v_und=aux%10;
v_dez=(aux/10)%10;
v_cent=((aux/10)/10)%10;
v_mil=((aux/10)/10)/10;
v_mil2=v_mil/10;
v_mil3=v_mil%10;
if(v_mil3 >= 1 && v_mil3 <= 9){
switch(v_mil3){
case 1:
strcpy(s_mil3,"Um");break;
case 2:
strcpy(s_mil3,"Dois");break;
case 3:
strcpy(s_mil3,"Tres");break;
case 4:
strcpy(s_mil3,"Quatro");break;
case 5:
strcpy(s_mil3,"Cinco");break;
case 6:
strcpy(s_mil3,"Seis");break;
case 7:
strcpy(s_mil3,"Sete");break;
case 8:
strcpy(s_mil3,"Oito");break;
case 9:
strcpy(s_mil3,"Nove");break;
}
}
if(v_mil2>=2 && v_mil2<=9){
switch(v_mil2){
case 2:
strcpy(s_mil2 ,"Vinte");break;
case 3:
strcpy(s_mil2 ,"Trinta");break;
case 4:
strcpy(s_mil2 ,"Quarenta");break;
case 5:
strcpy(s_mil2 ,"Cinquenta");break;
case 6:
strcpy(s_mil2 ,"Sessenta");break;
case 7:
strcpy(s_mil2 ,"Setenta");break;
case 8:
strcpy(s_mil2 ,"Oitenta");break;
case 9:
strcpy(s_mil2 ,"Noventa");break;
}
}
if(v_mil >= 1 && v_mil <= 19){
switch(v_mil){
case 1:
strcpy(s_mil1,"Mil");break;
case 2:
strcpy(s_mil1,"Dois Mil");break;
case 3:
strcpy(s_mil1,"Tres Mil");break;
case 4:
strcpy(s_mil1,"Quatro Mil");break;
case 5:
strcpy(s_mil1,"Cinco Mil");break;
case 6:
strcpy(s_mil1,"Seis Mil");break;
case 7:
strcpy(s_mil1,"Sete Mil");break;
case 8:
strcpy(s_mil1,"Oito Mil");break;
case 9:
strcpy(s_mil1,"Nove Mil");break;
case 10:
strcpy(s_mil1,"Dez Mil");break;
case 11:
strcpy(s_mil1,"Onze Mil");break;
case 12:
strcpy(s_mil1,"Dose Mil");break;
case 13:
strcpy(s_mil1,"Treze Mil");break;
case 14:
strcpy(s_mil1,"Quatorze Mil");break;
case 15:
strcpy(s_mil1,"Quinze Mil");break;
case 16:
strcpy(s_mil1,"Dezasseis Mil");break;
case 17:
strcpy(s_mil1,"Dezasete Mil");break;
case 18:
strcpy(s_mil1,"Dezoito Mil");break;
case 19:
strcpy(s_mil1,"Desanove Mil");break;
}
}
if(v_und >= 0 && v_und <= 9){
switch(v_und){
case 0:
strcpy(s_und,"Zero");break;
case 1:
strcpy(s_und,"Um");break;
case 2:
strcpy(s_und,"Dois");break;
case 3:
strcpy(s_und,"Tres");break;
case 4:
strcpy(s_und,"Quatro");break;
case 5:
strcpy(s_und,"Cinco");break;
case 6:
strcpy(s_und,"Seis");break;
case 7:
strcpy(s_und,"Sete");break;
case 8:
strcpy(s_und,"Oito");break;
case 9:
strcpy(s_und,"Nove");break;
}
}
if(v_dez==1){
v_dez=10+v_und;
switch(v_dez){
case 10:
strcpy(s_dez,"Dez");break;
case 11:
strcpy(s_dez,"Onze");break;
case 12:
strcpy(s_dez,"Doze");break;
case 13:
strcpy(s_dez,"Trese");break;
case 14:
strcpy(s_dez,"Quatorze");break;
case 15:
strcpy(s_dez,"Quinze");break;
case 16:
strcpy(s_dez,"Dezasseis");break;
case 17:
strcpy(s_dez,"Dezasete");break;
case 18:
strcpy(s_dez,"Dezoito");break;
case 19:
strcpy(s_dez,"Desanove");break;
}
}else{
switch(v_dez){
case 2:
strcpy(s_dez ,"Vinte");break;
case 3:
strcpy(s_dez ,"Trinta");break;
case 4:
strcpy(s_dez ,"Quarenta");break;
case 5:
strcpy(s_dez ,"Cinquenta");break;
case 6:
strcpy(s_dez ,"Sessenta");break;
case 7:
strcpy(s_dez ,"Setenta");break;
case 8:
strcpy(s_dez ,"Oitenta");break;
case 9:
strcpy(s_dez ,"Noventa");break;
}
}
if(v_cent == 1 && v_dez == 0 && v_und == 0){
switch(v_cent){
case 1:
strcpy(s_cent ,"Cem");break;
}
}else{
if(v_cent > 0 && (v_dez > 0 || v_und > 0)){
switch(v_cent){
case 1:
strcpy(s_cent ,"Cento");break;
case 2:
strcpy(s_cent ,"Duzentos");break;
case 3:
strcpy(s_cent ,"Trezentos");break;
case 4:
strcpy(s_cent ,"Quatrocentos");break;
case 5:
strcpy(s_cent ,"Quinhentos");break;
case 6:
strcpy(s_cent ,"Seiscentos");break;
case 7:
strcpy(s_cent ,"Setecentos");break;
case 8:
strcpy(s_cent ,"Oitocentos");break;
case 9:
strcpy(s_cent ,"Novecentos");break;
}
}else if(v_cent > 0 && v_dez == 0 && v_und == 0){
switch(v_cent){
case 1:
strcpy(s_cent ,"Cento");break;
case 2:
strcpy(s_cent ,"Duzentos");break;
case 3:
strcpy(s_cent ,"Trezentos");break;
case 4:
strcpy(s_cent ,"Quatrocentos");break;
case 5:
strcpy(s_cent ,"Quinhentos");break;
case 6:
strcpy(s_cent ,"Seiscentos");break;
case 7:
strcpy(s_cent ,"Setecentos");break;
case 8:
strcpy(s_cent ,"Oitocentos");break;
case 9:
strcpy(s_cent ,"Novecentos");break;
}
}
}
if(v_mil==0 && v_cent==0 && v_dez==0 && v_und<=9)
printf("%s",s_und);
if( v_mil==0 && v_cent==0 && v_dez >= 10 && v_dez < 20 && v_und >= 0)
printf("%s",s_dez);
if( v_mil==0 && v_cent==0 && v_dez >= 2 && v_dez <= 9 && v_und == 0)
printf("%s",s_dez);
if(v_mil==0 && v_cent == 0 && v_dez >= 2 && v_dez <= 9 && v_und > 0)
printf("%s e %s",s_dez,s_und);
if(v_mil==0 && (v_cent > 0 && v_cent <1000) && v_dez ==0 && v_und==0)
printf("%s",s_cent);
if(v_mil==0 && (v_cent > 0 && v_cent <1000) && v_dez== 0 && v_und > 0)
printf("%s e %s",s_cent,s_und);
if(v_mil==0 && (v_cent > 0 && v_cent <1000) && v_dez > 0 && v_und == 0)
printf("%s e %s",s_cent,s_dez);
if( v_mil==0 && (v_cent > 0 && v_cent <1000) && v_dez > 0 && v_und > 0)
printf("%s e %s e %s",s_cent,s_dez,s_und);
if((v_mil>=1 && v_mil<=19) && v_cent==0 && v_dez==0 && v_und == 0)
printf("%s",s_mil1);
if((v_mil>=1 && v_mil<=19) && (v_cent > 0 && v_cent <1000) && v_dez==0 && v_und == 0)
printf("%s e %s",s_mil1,s_cent);
if((v_mil>=1 && v_mil<=19) && (v_cent > 0 && v_cent <1000) && (v_dez >= 2 && v_dez <= 19) && v_und == 0)
printf("%s e %s e %s",s_mil1,s_cent,s_dez);
if((v_mil>=1 && v_mil<=19) && (v_cent > 0 && v_cent <1000) && (v_dez >= 2 && v_dez <= 19) && v_und >=1)
printf("%s e %s e %s e %s",s_mil1,s_cent,s_dez,s_und);
if((v_mil>=1 && v_mil<=19) && v_cent==0 && v_dez==0 && v_und >=1)
printf("%s e %s",s_mil1,s_und);
if((v_mil>=1 && v_mil<=19) && v_cent==0 && (v_dez >= 2 && v_dez <= 19) && v_und >=0){
if(v_und!=0)
printf("%s e %s e %s",s_mil1,s_dez,s_und);
else
printf("%s e %s",s_mil1,s_dez);
}
if((v_mil>=1 && v_mil<=19) && (v_cent > 0 && v_cent <1000) && (v_dez==0) && v_und >=1)
printf("%s e %s e %s",s_mil1,s_cent,s_und);
if((v_mil2>=2 && v_mil2<=9) && v_mil3>=0 && v_cent==0 && v_dez==0 && v_und == 0){
if(v_mil3==0)
printf("%s Mil",s_mil2);
else
printf("%s e %s Mil",s_mil2,s_mil3);
}
if((v_mil2>=2 && v_mil2<=9)&& v_mil3>=0 && v_cent==0 && v_dez==0 && v_und >=1)
{
if(v_mil3==0)
printf("%s Mil e %s",s_mil2,s_und);
else
printf("%s e %s Mil e %s",s_mil2,s_mil3,s_und);
}
if((v_mil2>=2 && v_mil2<=9)&& v_mil3>=0 && v_cent==0 && v_dez>=0 && v_und >=0)
{
if(v_dez==0){
}else
if(v_mil3==0)
if(v_dez==0){
}else
if(v_und==0)
printf("%s Mil e %s",s_mil2,s_dez);
else
printf("%s Mil e %s e %s",s_mil2,s_dez,s_und);
else
printf("%s e %s Mil e %s",s_mil2,s_mil3,s_dez);
}
if((v_mil2>=2 && v_mil2<=9)&& v_mil3>=0 && v_cent>=1 && v_dez==0 && v_und ==0)
{
if(v_mil3==0)
printf("%s Mil e %s",s_mil2,s_cent);
else
printf("%s e %s Mil e %s",s_mil2,s_mil3,s_cent);
}
if((v_mil2>=2 && v_mil2<=9)&& v_mil3>=0 && v_cent>=1 && v_dez==0 && v_und>0)
{
if(v_mil3==0)
printf("%s Mil e %s e %s",s_mil2,s_cent,s_und);
else
printf("%s e %s Mil e %s e %s",s_mil2,s_mil3,s_cent,s_und);
}
if((v_mil2>=2 && v_mil2<=9)&& v_mil3>=0 && v_cent>=1 && v_dez>=1 && v_und==0)
{
if(v_mil3==0)
printf("%s Mil e %s e %s",s_mil2,s_cent,s_dez);
else
printf("%s e %s Mil e %s e %s",s_mil2,s_mil3,s_cent,s_dez);
}
if((v_mil2>=2 && v_mil2<=9)&& v_mil3>=0 && v_cent>=1 && v_dez>=1 && v_und>=1)
{
if(v_mil3==0)
printf("%s Mil e %s e %s e %s",s_mil2,s_cent,s_dez,s_und);
else
printf("%s e %s Mil e %s e %s e %s",s_mil2,s_mil3,s_cent,s_dez,s_und);
}
}
int main(){
int d;
while(1){
scanf("%d",&d);
por_extenso(d);
}
}