Exemplo n.º 1
0
 public static void main(String[] args) {
   int N = Integer.parseInt(args[0]);
   StdDraw.setCanvasSize(160, 640);
   StdDraw.setXscale(-1, N + 1);
   StdDraw.setPenRadius(.006);
   double[] a = new double[N];
   for (int i = 0; i < N; i++) a[i] = Math.random();
   sort(a);
 }
Exemplo n.º 2
0
  // test client
  public static void main(String[] args) {
    // parse command-line argument as an array of 1-character strings
    String s = "EASYQUESTION";
    int N = s.length();
    String[] a = new String[N];
    for (int i = 0; i < N; i++) a[i] = s.substring(i, i + 1);

    // set canvas size
    StdDraw.setCanvasSize(30 * (N + 3), 30 * (N + 3));
    StdDraw.setXscale(-3, N + 1);
    StdDraw.setYscale(N + 1, -3);
    StdDraw.setFont(new Font("SansSerif", Font.PLAIN, 13));

    // draw the header
    header(a);

    // sort the array
    sort(a);

    // draw the footer
    footer(a);
  }