Advertisement
dydziek

ASiD kosmonauci wystarczająca

Nov 5th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. package algorytmy;
  2.  
  3. /**
  4.  * kosmonauciZachlannie
  5.  */
  6. public class kosmonauciZachlannie {
  7.  
  8.     /*
  9.     a = k1 k4
  10.     b = k2 k3 k4
  11.     c = k3 k5
  12.     d = k1 k2 k5
  13.      */
  14.  
  15.     int[] listaKosmonautowDoWziecia = new int[5];
  16.     static int a, b, c, d, numerKosmonauty = 0;
  17.  
  18.     public static void main(String[] args) {
  19.         while ( a == 0 || b == 0 || c == 0 || d == 0 ) {
  20.             switch ( numerKosmonauty ) {
  21.                 case 0:
  22.                     a++;
  23.                     d++;
  24.                     break;
  25.                
  26.                 case 1:
  27.                     b++;
  28.                     d++;
  29.                     break;
  30.                
  31.                 case 2:
  32.                     b++;
  33.                     c++;
  34.                     break;
  35.  
  36.                 case 3:
  37.                     a++;
  38.                     b++;
  39.                     break;
  40.  
  41.                 case 4:
  42.                     c++;
  43.                     d++;
  44.                     break;
  45.            
  46.                 default:
  47.                     break;
  48.             }
  49.             System.out.println("Na pokład trafia kosmonauta " + numerKosmonauty);
  50.             numerKosmonauty++;
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement