GatoBooster

Cabeza de Chancho

Aug 23rd, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.25 KB | None | 0 0
  1. #include  <stdio.h>
  2.  
  3. int main(void)
  4. {  
  5. //Declaro las variables a usar
  6.     unsigned long long L;
  7.    
  8.     signed short l;
  9.     unsigned long long i;
  10.     unsigned long long R;
  11.     unsigned long long pot10;
  12.     unsigned long long copiaI;
  13.    
  14.     unsigned long long vectorColas[1000000];
  15.    
  16.     unsigned short j,k;
  17.    
  18.    
  19.     unsigned short auxiliar;
  20.     unsigned short longDigitos;
  21.     unsigned short vectorDigitos[20];
  22.    
  23.     unsigned short contColasNC;
  24.    
  25.    
  26. //Ingreso el rango de numeros que voy a verificar
  27.     scanf("%llu%llu",&L,&R);
  28.    
  29.    
  30.     contColasNC = 0;
  31.    
  32. //Repito el proceso la cantidad de veces necesarias
  33.     for (i = L ; i <= R ; i++)
  34.     {    
  35.         copiaI = i;
  36.         longDigitos = 0;
  37.  
  38.     // Cuento la cantidad de digitos e ingreso los digitos del numero al vector
  39.         while (copiaI != 0)
  40.         {
  41.             if (copiaI % 10 != 0)
  42.             {
  43.                 vectorDigitos[longDigitos] = copiaI % 10;
  44.                 longDigitos++;
  45.             }
  46.  
  47.             copiaI = copiaI / 10;
  48.         }
  49.    
  50.     //Ordeno los digitos dentro del vector
  51.         for (j = 0 ; j < longDigitos - 1 ; j++)
  52.         {
  53.             for ( k = 1 ; k < longDigitos ; k++)
  54.             {
  55.                 if (vectorDigitos[j] > vectorDigitos[k])
  56.                 {
  57.                         auxiliar = vectorDigitos[j];
  58.                         vectorDigitos[j] = vectorDigitos[k];
  59.                         vectorDigitos[k] = auxiliar;
  60.                 }
  61.             }
  62.         }
  63.        
  64.         copiaI = 0;
  65.         pot10 = 1;
  66.     //Rehago el numero sin los 0
  67.         for (l = longDigitos - 1 ; l >= 0; l--)
  68.         {
  69.             copiaI = copiaI + vectorDigitos[l] * pot10;
  70.             pot10 = pot10 * 10;
  71.         }
  72.      
  73.         //printf("%llu ",copiaI);
  74.         int noEsta = 1;
  75.         j = 0;
  76.        
  77.         while (noEsta && (j < contColasNC)) {
  78.             if (vectorColas[j] == copiaI) {
  79.                 noEsta = 0;
  80.             }
  81.             else {
  82.                 j++;
  83.             }
  84.         }
  85.         if (noEsta) {
  86.             vectorColas[contColasNC] = copiaI;
  87.             contColasNC++;
  88.         }
  89.        
  90.        
  91.        
  92.     }
  93.     printf("%u",contColasNC);
  94.    
  95.     return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment