001package algs11; 002import stdlib.*; 003import java.util.Arrays; 004public class XDrawArraySorted { 005 public static void main (String[] args) { 006 int N = 50; 007 double[] a = new double[N]; 008 for (int i = 0; i < N; i++) 009 a[i] = StdRandom.random (); 010 Arrays.sort (a); 011 for (int i = 0; i < N; i++) { 012 double x = 1.0 * i / N; 013 double y = a[i] / 2.0; 014 double rw = 0.25 / N; 015 double rh = a[i] / 2.0; 016 StdDraw.filledRectangle (x, y, rw, rh); 017 } 018 } 019}