Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.53 KB | None | 0 0
  1. void seleccionNumero(int a[5],int b){
  2.    
  3.     char x[6] = {0,0,0,0,0,0};
  4.     int k = 0;
  5.     while(k == 0){
  6.     printf("Seleccione un numero de %i cifras distintas entre si:  ",b);
  7.     scanf("%s",&x);
  8.    
  9.         switch (b){
  10.             case 2:
  11.                 if((x[0] >= 48) && (x[0] <= 57)){
  12.                     if((x[1] >= 48) && (x[1] <= 57)){
  13.                         if(x[2] == 0){
  14.                             k = 1;
  15.                             break;
  16.                         } } }
  17.                 break;
  18.             case 3:
  19.                 if((x[0] >= 48) && (x[0] <= 57)){
  20.                     if((x[1] >= 48) && (x[1] <= 57)){
  21.                         if((x[2] >= 48) && (x[2] <= 57)){
  22.                             if(x[3] == 0){
  23.                                 k = 1;
  24.                                 break;
  25.                             } } } }
  26.                 break;
  27.             case 4:
  28.                 if((x[0] >= 48) && (x[0] <= 57)){
  29.                     if((x[1] >= 48) && (x[1] <= 57)){
  30.                         if((x[2] >= 48) && (x[2] <= 57)){
  31.                             if((x[3] >= 48) && (x[3] <= 57)){
  32.                                 if(x[4] == 0){
  33.                                     k = 1;
  34.                                     break;
  35.                                 } } } } }
  36.                  break;
  37.             case 5:
  38.                 if((x[0] >= 48) && (x[0] <= 57)){
  39.                     if((x[1] >= 48) && (x[1] <= 57)){
  40.                         if((x[2] >= 48) && (x[2] <= 57)){
  41.                             if((x[3] >= 48) && (x[3] <= 57)){
  42.                                 if((x[4] >= 48) && (x[4] <= 57)){
  43.                                     if(x[5] == 0){
  44.                                         k = 1;
  45.                                         break;
  46.                                     } } } } } }
  47.                  break;
  48.         }
  49.           }      
  50.    
  51.     for(int i = 0; i < b; i++){
  52.                
  53.         a[i] = x[i] - 48;
  54.        
  55.     }
  56.    
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement