isefire

Hairdo

Jul 27th, 2014
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. public class Hairdo
  2. {
  3.     public static boolean should(boolean[] j)
  4.     {
  5.         int k = 0; //false
  6.         int z = 0; //true
  7.         for (int i = 0; i < j.length; i++)
  8.         {
  9.             if (j[i] == false) k+=1;
  10.             else z+=1;
  11.         }
  12.         if (k >= z) return false;
  13.         return true;
  14.     }
  15.     public static boolean[] hairdo(boolean[] j)
  16.     {
  17.         for (int i = 0; i < j.length; i++)
  18.         {
  19.             double c = Math.random();
  20.             if (c >= .5) j[i] = true;
  21.         }
  22.         return j;
  23.     }
  24.     public static void main(String[] args)
  25.     {
  26.         // length of array
  27.         int num = Integer.parseInt(args[0]);
  28.         boolean[] j = new boolean[num];
  29.         j = hairdo(j);
  30.         boolean a = should(j);
  31.         if (a==true) System.out.println("Pixie");
  32.         else System.out.println("Long");
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment