TheMalva

Primer_Parcial_2018_Ej_2

Aug 21st, 2018
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. ##Ejercicio Nro 2 del primer parcial año 2018
  2.  
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <time.h>
  6.  
  7. int funcRandom();
  8.  
  9. int main()
  10. {
  11.     int valor;
  12.  
  13.     valor=funcRandom();
  14.     printf("El numero generado fue: %d", valor);
  15.     return 0;
  16. }
  17.  
  18.  
  19. int funcRandom()
  20. {
  21.     int valor_random, u, d, c, um, dm, valor_correcto, bandera=0;
  22.     srand(time(0));
  23.     do{
  24.         valor_random = (rand() % (30000 + 1 - 10000)) + 10000;
  25.         valor_correcto = valor_random;
  26.        
  27.         u = valor_random % 10;
  28.         valor_random = valor_random /10;
  29.         d = valor_random % 10;
  30.         valor_random = valor_random /10;
  31.         c = valor_random % 10;
  32.         valor_random = valor_random /10;
  33.         um = valor_random % 10;
  34.         valor_random = valor_random /10;
  35.         dm = valor_random % 10;
  36.         valor_random = valor_random /10;
  37.        
  38.         printf("%d\n", valor_correcto);
  39.  
  40.         if((u == d && u == c) || (d == c && d == um) || (c == um && c == dm))
  41.             bandera=1;
  42.  
  43.     }while(bandera == 0);
  44.  
  45.  
  46.     return valor_correcto;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment