Advertisement
isabelgh

Main

Sep 9th, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. import edu.princeton.cs.algs4.Stopwatch;
  2.  
  3. public class Main {
  4.    
  5.     public static void main(String[] args) {
  6.        
  7.        
  8.         System.out.println("Iterative pascal : ");
  9.         Stopwatch sw1 = new Stopwatch();
  10.         Pascal p = new IterativePascal();
  11.         p.printPascal(50);
  12.         double t1 = sw1.elapsedTime();
  13.        
  14.         System.out.println();
  15.        
  16.         System.out.println("Recursive pascal : ");
  17.         Stopwatch sw2 = new Stopwatch();
  18.         Pascal p1 = new RecursivePascal();
  19.         p1.printPascal(4);
  20.         double t2 = sw2.elapsedTime();
  21.        
  22.         System.out.println();
  23.        
  24.         System.out.println("Fast pascal : ");
  25.         Stopwatch sw3 = new Stopwatch();
  26.         PascalFast p2 = new PascalFast ();
  27.         p2.printPascal(50);
  28.         double t3 = sw3.elapsedTime();
  29.        
  30.         System.out.println("Iterative: " + t1 + " s");
  31.         System.out.println("Recursive: " + t2 + " s");
  32.         System.out.println("Fast: " + t3 + " s");
  33.  
  34.        
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement