Exemplo n.º 1
0
Arquivo: set.java Projeto: wcyuan/Set
      public static void main(String[] args) {

        if (args.length < 3) return;

        int a = java.lang.Integer.parseInt(args[0]);
        int b = java.lang.Integer.parseInt(args[1]);
        int c = java.lang.Integer.parseInt(args[2]);
        int mask = 1, div = 3;
        int x, y, z;
        // a--; b--; c--;
        for (int i = 0; i < 4; i++) {
          x = (a % div);
          y = (b % div);
          z = (c % div);
          System.out.println(
              "mask: " + mask + " div: " + div + " x: " + x + " y: " + y + " z: " + z);
          x /= mask;
          y /= mask;
          z /= mask;
          if (!(x == y && x == z) && !(x != y && x != z && y != z)) {
            System.out.println(
                "mask: " + mask + " div: " + div + " x: " + x + " y: " + y + " z: " + z);
            return;
          }
          mask *= 3;
          div *= 3;
        }
        return;

        /*
          if (IsSet(java.lang.Integer.parseInt(args[0]),
          java.lang.Integer.parseInt(args[1]),
          java.lang.Integer.parseInt(args[2])))
          {
          System.out.println("YES");
          } else
          {
          System.out.println("NO");
          }

          Cards c = new Cards(21);
          for (int j = 0; j < 2; j++)
          for (int i = 0; i < 21; i++)
          {
          System.out.println(i + " " + c.NextCard());
          }
        */
      }
  /**
   * @param value
   * @param type
   * @return
   */
  private Object createTypedObject(String value, Class type) {
    if (java.lang.String.class == type) return value;
    else if (java.lang.Integer.class == type) return java.lang.Integer.parseInt(value);
    else if (java.lang.Long.class == type) return java.lang.Long.parseLong(value);
    else if (java.lang.Boolean.class == type) return java.lang.Boolean.parseBoolean(value);
    else if (java.lang.Float.class == type) return java.lang.Float.parseFloat(value);
    else if (java.lang.Double.class == type) return java.lang.Double.parseDouble(value);

    return null;
  }