Advertisement
polectron

Untitled

Feb 10th, 2017
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. public static void main(String arg[]) {
  2. float nTimes = Integer.parseInt(arg[1]); // nTimes
  3. int option = Integer.parseInt(arg[0]); // selected option
  4. long t1, t2;
  5.  
  6. for (int n = 3; n <= 768; n *= 2) {
  7. a = new int[n][n];
  8. // n is incremented * 2
  9. t1 = System.currentTimeMillis();
  10. for (int times = 1; times <= nTimes; times++) {
  11. if (option == 0) { // fill in the matrix
  12. Diagonal1.fillIn(a);
  13. } // if
  14. else if (option == 1) { // sum of the diagonal (one way)
  15. Diagonal1.sum1Diagonal(a);
  16. } // else if
  17. else if (option == 2) { // sum of the diagonal (another way)
  18. Diagonal1.sum2Diagonal(a);
  19. } // else if
  20. else {
  21. System.out.println("INCORRECT OPTION");
  22. }
  23. }
  24. t2 = System.currentTimeMillis();
  25. System.out.println("n: " + n + " Time: " + ((t2 - t1) / nTimes) + " -> " + (t2 - t1));
  26. }
  27. } // main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement