numeros a letras, recursivamente
necesito el program en c++, q convierta los enteros a letras con recursion,porfa ya no hay tiempo.
¿Qué es exáctamente lo que necesitas? ¿Que el programa convierta un numero a su representacion en palabras ó que quede la misma representacion pero nada mas cambiar el tipo de dato?
Por ejemplo:
142 = ciento cuarenta y dos
ó
142 = "142"
Por ejemplo:
142 = ciento cuarenta y dos
ó
142 = "142"
Ojala te sirva!!
si conoces a alguein k me pueda ayudar en arboles B* te lo agradeceria mas ..
#include<stdio.h>
#include <conio.h>
#include<string.h>
int lee_numeros();
int interpreta_valor(int);
int escriba_valor();
char *a[]={"uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"};
char *b[]={"once","doce","trece","catorce","quince"};
char *c[]={"diez","veinte","treinta","cuarenta","cincuenta","sesenta",
"setenta","ochenta","noventa"};
char *d[]={ "cien","dosientos ","trecientos ","cuatrocientos ","quinientos ",
"seisciento ","setecientos ","ochocientos ","novecientos " };
char e[100];
int main() {
clrscr();
char p;
int l;
p='s';
while(p=='s'|| p=='S')
{
clrscr();
l=lee_numeros();
interpreta_valor(l);
escriba_valor();
printf("nnDesea introducir otro numero s(si),n(no)",p);
cscanf("%c",&p);
getch();
}
}
int lee_numeros()
{ int cc;
printf("n Introducir un numero:");
scanf("%d",&cc);
return cc;
}
int interpreta_valor(int cc)
{
int ss,pp,tt,ll;
ss=cc%10 ;
tt=cc/10;
pp=tt%10;
ll=tt/10;
strcpy(e," ");
if(ll==1 && (ss!=0 || pp!=0)){
strcat(e,d[ll-1]);
strcat(e,"to ");
}
if(ll>0 && ss==0 && pp==0) strcat(e,d[ll-1]);
if(ll>1 && (ss!=0 || pp!=0)) strcat(e,d[ll-1]);
if(pp!=0 || ss!=0)
{
if(pp==0) strcat(e,a[ss-1]);
if(pp>=1 && ss==0) strcat(e,c[pp-1]);
if(ss<6 && pp==1 && ss!=0) strcat(e,b[ss-1]);
else if(ss>5 && pp==1)
{
strcat(e,c[pp-1]);
strcat(e," y ");
strcat(e,a[ss-1]);
}
if(pp>=2 && ss!=0)
{
strcat(e,c[pp-1]);
strcat(e," y ");
strcat(e,a[ss-1]);
}
}
return 0;
}
int escriba_valor()
{
printf("n %s ",e);
getch();
return (0);
}
si conoces a alguein k me pueda ayudar en arboles B* te lo agradeceria mas ..
#include<stdio.h>
#include <conio.h>
#include<string.h>
int lee_numeros();
int interpreta_valor(int);
int escriba_valor();
char *a[]={"uno","dos","tres","cuatro","cinco","seis","siete","ocho","nueve"};
char *b[]={"once","doce","trece","catorce","quince"};
char *c[]={"diez","veinte","treinta","cuarenta","cincuenta","sesenta",
"setenta","ochenta","noventa"};
char *d[]={ "cien","dosientos ","trecientos ","cuatrocientos ","quinientos ",
"seisciento ","setecientos ","ochocientos ","novecientos " };
char e[100];
int main() {
clrscr();
char p;
int l;
p='s';
while(p=='s'|| p=='S')
{
clrscr();
l=lee_numeros();
interpreta_valor(l);
escriba_valor();
printf("nnDesea introducir otro numero s(si),n(no)",p);
cscanf("%c",&p);
getch();
}
}
int lee_numeros()
{ int cc;
printf("n Introducir un numero:");
scanf("%d",&cc);
return cc;
}
int interpreta_valor(int cc)
{
int ss,pp,tt,ll;
ss=cc%10 ;
tt=cc/10;
pp=tt%10;
ll=tt/10;
strcpy(e," ");
if(ll==1 && (ss!=0 || pp!=0)){
strcat(e,d[ll-1]);
strcat(e,"to ");
}
if(ll>0 && ss==0 && pp==0) strcat(e,d[ll-1]);
if(ll>1 && (ss!=0 || pp!=0)) strcat(e,d[ll-1]);
if(pp!=0 || ss!=0)
{
if(pp==0) strcat(e,a[ss-1]);
if(pp>=1 && ss==0) strcat(e,c[pp-1]);
if(ss<6 && pp==1 && ss!=0) strcat(e,b[ss-1]);
else if(ss>5 && pp==1)
{
strcat(e,c[pp-1]);
strcat(e," y ");
strcat(e,a[ss-1]);
}
if(pp>=2 && ss!=0)
{
strcat(e,c[pp-1]);
strcat(e," y ");
strcat(e,a[ss-1]);
}
}
return 0;
}
int escriba_valor()
{
printf("n %s ",e);
getch();
return (0);
}
