#include<conio.h>
#include<stdio.h>
#include<string.h>
struct num{
       char numer[10];
       int n1;
       int n2;
       int n3;
       int n4;
       }nu;
struct nom{
       char n1[20];
       char n2[20];
       char n3[20];
       char n4[20];
       }no;
void nume (char *);
int main (void)
{
    printf("Ingresa el numero, max hasta 9999\n");
    gets(nu.numer);
    nume(nu.numer);
    printf("Oprime una tecla para terminar...\n");
    getch();
    return 0;
}

void nume (char *numer)
{
     int i,c;
     c=1;
     for(;*numer!=NULL;numer++)   
     {
     switch(c)
     {
     case 1: if(*numer==48)
             nu.n1=0;
           else
             if(*numer==49)
               nu.n1=1;
             else
               if(*numer==50)
                 nu.n1=2;
               else
                 if(*numer==51)
                   nu.n1=3;
                 else
                   if(*numer==52)
                     nu.n1=4;
                   else
                     if(*numer==53)
                       nu.n1=5;
                     else 
                       if(*numer==54)
                         nu.n1=6;
                       else 
                         if(*numer==55)
                           nu.n1=7;
                         else 
                           if(*numer==56)
                             nu.n1=8;
                           else 
                             if(*numer==57)
                               nu.n1=9;
                               break;
     case 2:     if(*numer==48)
             nu.n2=0;
           else
             if(*numer==49)
               nu.n2=1;
             else
               if(*numer==50)
                 nu.n2=2;
               else
                 if(*numer==51)
                   nu.n2=3;
                 else
                   if(*numer==52)
                     nu.n2=4;
                   else
                     if(*numer==53)
                       nu.n2=5;
                     else 
                       if(*numer==54)
                         nu.n2=6;
                       else 
                         if(*numer==55)
                           nu.n2=7;
                         else 
                           if(*numer==56)
                             nu.n2=8;
                           else 
                             if(*numer==57)
                               nu.n2=9;
                             break;
     case 3:     if(*numer==48)
             nu.n3=0;
           else
             if(*numer==49)
               nu.n3=1;
             else
               if(*numer==50)
                 nu.n3=2;
               else
                 if(*numer==51)
                   nu.n3=3;
                 else
                   if(*numer==52)
                     nu.n3=4;
                   else
                     if(*numer==53)
                       nu.n3=5;
                     else 
                       if(*numer==54)
                         nu.n3=6;
                       else 
                         if(*numer==55)
                           nu.n3=7;
                         else 
                           if(*numer==56)
                             nu.n3=8;
                           else 
                             if(*numer==57)
                               nu.n3=9;
                           break;
     case 4:      if(*numer==48)
             nu.n4=0;
           else
             if(*numer==49)
               nu.n4=1;
             else
               if(*numer==50)
                 nu.n4=2;
               else
                 if(*numer==51)
                   nu.n4=3;
                 else
                   if(*numer==52)
                     nu.n4=4;
                   else
                     if(*numer==53)
                       nu.n4=5;
                     else 
                       if(*numer==54)
                         nu.n4=6;
                       else 
                         if(*numer==55)
                           nu.n4=7;
                         else 
                           if(*numer==56)
                             nu.n4=8;
                           else 
                             if(*numer==57)
                               nu.n4=9;
                               break;
     default:  printf("");
              
              
                           
     }
   c=c+1;
   }
   printf("\n\n");


     
     if(nu.n1==0)
       strcpy(no.n1,"");
     else
       if(nu.n1==1)
         strcpy(no.n1,"Mil");
       else
         if(nu.n1==2)
           strcpy(no.n1,"Dos mil");
         else
           if(nu.n1==3)
             strcpy(no.n1,"Tres mil");
           else
             if(nu.n1==4)
               strcpy(no.n1,"Cuatro mil");
             else
               if(nu.n1==5)
                strcpy(no.n1,"Cinco mil");
               else
                 if(nu.n1==6)
                   strcpy(no.n1,"Seis mil");
                 else
                   if(nu.n1==7)
                     strcpy(no.n1,"Siete mil");
                   else
                     if(nu.n1==8)
                       strcpy(no.n1,"Ocho mil");
                     else
                       if(nu.n1==9)
                         strcpy(no.n1,"Nueve mil");
                         
                       
     if(nu.n2==0)
       strcpy(no.n2,"");
     else
       if(nu.n2==1)
         strcpy(no.n2,"ciento");
       else
         if(nu.n2==2)
           strcpy(no.n2,"doscientos");
         else
           if(nu.n2==3)
             strcpy(no.n2,"trescientos");
           else
             if(nu.n2==4)
               strcpy(no.n2,"cuatrocientos");
             else
               if(nu.n2==5)
                strcpy(no.n2,"quinientos");
               else
                 if(nu.n2==6)
                   strcpy(no.n2,"seiscientos");
                 else
                   if(nu.n2==7)
                     strcpy(no.n2,"setecientos");
                   else
                     if(nu.n2==8)
                       strcpy(no.n2,"ochocientos");
                     else
                       if(nu.n2==9)
                         strcpy(no.n2,"novecientos");
      
       switch(nu.n4)
       {
         case 0: switch(nu.n3)
                 {
                   case 0: strcpy(no.n3,"");
                           strcpy(no.n4,"");
                           break;
                   case 1: strcpy(no.n3,"diez");
                           strcpy(no.n4,"");
                           break;
                   case 2: strcpy(no.n3,"veinte");
                           strcpy(no.n4,"");
                           break;
                   case 3: strcpy(no.n3,"treinta");
                           strcpy(no.n4,"");
                           break;
                   case 4: strcpy(no.n3,"cuarenta");
                           strcpy(no.n4,"");
                           break;
                   case 5: strcpy(no.n3,"cincuenta");
                           strcpy(no.n4,"");
                           break;
                   case 6: strcpy(no.n3,"sesenta");
                           strcpy(no.n4,"");
                           break;
                   case 7: strcpy(no.n3,"setenta");
                           strcpy(no.n4,"");
                           break;
                   case 8: strcpy(no.n3,"ochenta");
                           strcpy(no.n4,"");
                           break;
                   case 9: strcpy(no.n3,"noventa");
                           strcpy(no.n4,"");
                           break;
                   default:strcpy(no.n3,"");
                           strcpy(no.n4,"");
                   }
                   break;
         case 1: strcpy(no.n4,"uno");
                 break;
         case 2: strcpy(no.n4,"dos");
                 break;
         case 3: strcpy(no.n4,"tres");
                 break;
         case 4: strcpy(no.n4,"cuatro");
                 break;
         case 5: strcpy(no.n4,"cinco");
                 break;
         case 6: strcpy(no.n4,"seis");
                 break;
         case 7: strcpy(no.n4,"siete");
                 break;
         case 8: strcpy(no.n4,"ocho");
                 break;
         case 9: strcpy(no.n4,"nueve");
                 break;
         default: strcpy(no.n4,"");
        }
        
                   
        switch(nu.n3)
       {
         case 0: strcpy(no.n3,"");
                 break;
         case 1: switch(nu.n4)
                 {
                   case 0: strcpy(no.n3,"diez");
                           strcpy(no.n4,"");
                           break;
                   case 1: strcpy(no.n3,"once");
                           strcpy(no.n4,"");
                           break;
                   case 2: strcpy(no.n3,"doce");
                           strcpy(no.n4,"");
                           break;
                   case 3: strcpy(no.n3,"trece");
                           strcpy(no.n4,"");
                           break;
                   case 4: strcpy(no.n3,"catorce");
                           strcpy(no.n4,"");
                           break;
                   case 5: strcpy(no.n3,"quince");
                           strcpy(no.n4,"");
                           break;
                   case 6: strcpy(no.n3,"dieciseis");
                           strcpy(no.n4,"");
                           break;
                   case 7: strcpy(no.n3,"diecisiete");
                           strcpy(no.n4,"");
                           break;
                   case 8: strcpy(no.n3,"dieciocho");
                           strcpy(no.n4,"");
                           break;
                   case 9: strcpy(no.n3,"diecinueve");
                           strcpy(no.n4,"");
                           break;
                   default:strcpy(no.n3,"");
                           strcpy(no.n4,"");
                   }
                   break;
         case 2: strcpy(no.n3,"veinti");
                 break;
         case 3: strcpy(no.n3,"treinta y ");
                 break;
         case 4: strcpy(no.n3,"cuarenta y ");
                 break;
         case 5: strcpy(no.n3,"cincuenta y ");
                 break;
         case 6: strcpy(no.n3,"sesenta y ");
                 break;
         case 7: strcpy(no.n3,"setnta y ");
                 break;
         case 8: strcpy(no.n3,"ochenta y ");
                 break;
         case 9: strcpy(no.n3,"noventa y ");
                 break;
         default: strcpy(no.n3,"");
        }                
       
       
       
       if(nu.n4==0&&nu.n3==0&&nu.n2==1)
         {
           strcpy(no.n3,"cien");
           strcpy(no.n2,"");
           strcpy(no.n1,"");
         }
       else
       {
          if(nu.n1==0&&nu.n2==0&&nu.n3==0&&nu.n4==0)
          {
            strcpy(no.n2,"");
            strcpy(no.n1,"Cero");
          }
       }
       printf("El numero es: %s %s %s %s\n",no.n1,no.n2,no.n3,no.n4);

}
                         
     
           
         
     
