Código:
Muchisimas gracias a todos. #include <stdio.h> #include<iostream> using namespace std; int main() { int num[10]; int i,j=1,p; cout<<"Introduce un numero \n"<<endl; for(i=0;(num[i]=getchar()) != '\n';i++); if(i>6&&i<=9) p=6; else if(i>3&&i<=6) { p=3; j++; } else if(i>0&&i<=3) { p=0; j+=2; } for(j=j;j<=3;j++) { /*centenas*/ if((i==3 || i==6)||(num[0]!='\0' || num[3]!='\0' || num[6]!='\0') ) switch(num[i-(3+p)]) { case'1':if((num[(i-(3+p))+1]!='0') || (num[(i-(3+p))+2]!='0')) cout<<"ciento "<<endl; else cout<<"cien "<<endl; break; case'2':cout<<"doscientos "<<endl;break; case'3':cout<<"trescientos "<<endl;break; case'4':cout<<"cuatrocientos "<<endl;break; case'5':cout<<"quinientos "<<endl;break; case'6':cout<<"seiscientos "<<endl;break; case'7':cout<<"setecientos "<<endl;break; case'8':cout<<"ochocientos "<<endl;break; case'9':cout<<"novecientos "<<endl;break; } /*decenas*/ switch(num[i-(p+2)]) { case'1':switch(num[(i-(p+2))+1]) { case'0':cout<<"diez "<<endl;break; case'1':cout<<"once "<<endl;break; case'2':cout<<"doce "<<endl;break; case'3':cout<<"trece "<<endl;break; case'4':cout<<"catorce "<<endl;break; case'5':cout<<"quince "<<endl;break; case'6':cout<<"diesciseis "<<endl;break; case'7':cout<<"diescisiete "<<endl;break; case'8':cout<<"diesciocho "<<endl;break; case'9':cout<<"diescinueve "<<endl;break; }break; case'2':if(num[(i-(p+2))+1]=='0') cout<<"veinte "<<endl; else cout<<"veinti"<<endl; break; case'3':cout<<"treinta "<<endl; if(num[(i-1)-p]!='0') cout<<"y "<<endl; break; case'4':cout<<"cuarenta "<<endl; if(num[(i-1)-p]!='0') cout<<"y "<<endl; break; case'5':cout<<"cincuenta "<<endl; if(num[(i-1)-p]!='0') cout<<"y "<<endl; break; case'6':cout<<"secenta "<<endl; if(num[(i-1)-p]!='0') cout<<"y "<<endl; break; case'7':cout<<"setenta "<<endl; if(num[(i-1)-p]!='0') cout<<"y "<<endl; break; case'8':cout<<"ochenta "<<endl; if(num[(i-1)-p]!='0') cout<<"y "<<endl; break; case'9':cout<<"noventa "<<endl; if(num[(i-1)-p]!='0') cout<<"y "<<endl; break; } /*unidades*/ if(num[i-(p+2)]!='1') switch(num[(i-1)-p]) { case'1':if(p>=3) cout<<"un "<<endl; else cout<<"uno"<<endl; break; case'2':cout<<"dos "<<endl;break; case'3':cout<<"tres "<<endl;break; case'4':cout<<"cuatro "<<endl;break; case'5':cout<<"cinco "<<endl;break; case'6':cout<<"seis "<<endl;break; case'7':cout<<"siete "<<endl;break; case'8':cout<<"ocho "<<endl;break; case'9':cout<<"nueve "<<endl;break; } if(p==6 && num[0]=='0' && p==6 && num[1]=='0' && p==6 && num[2]=='0'); else if(p==6 && num[0]=='1' && i==7) cout<<"millon "<<endl; else if(p==6) cout<<"millones "<<endl; if(p==3 && num[p]!='0'|| p==3 && num[p+1]!='0' || p==3 && num[p+2]!='0')cout<<"mil "<<endl; p-=3; } getchar(); return 0; }