Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String arg[]) {
- float nTimes = Integer.parseInt(arg[1]); // nTimes
- int option = Integer.parseInt(arg[0]); // selected option
- long t1, t2;
- for (int n = 3; n <= 768; n *= 2) {
- a = new int[n][n];
- // n is incremented * 2
- t1 = System.currentTimeMillis();
- for (int times = 1; times <= nTimes; times++) {
- if (option == 0) { // fill in the matrix
- Diagonal1.fillIn(a);
- } // if
- else if (option == 1) { // sum of the diagonal (one way)
- Diagonal1.sum1Diagonal(a);
- } // else if
- else if (option == 2) { // sum of the diagonal (another way)
- Diagonal1.sum2Diagonal(a);
- } // else if
- else {
- System.out.println("INCORRECT OPTION");
- }
- }
- t2 = System.currentTimeMillis();
- System.out.println("n: " + n + " Time: " + ((t2 - t1) / nTimes) + " -> " + (t2 - t1));
- }
- } // main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement