Advertisement
DanikYakush

Task35

Jul 7th, 2022
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 KB | None | 0 0
  1. public static double[][] task35(int n) {
  2.         double[][] ans = new double[n][n];
  3.         int counter =0;
  4.         for (int i = 0; i < n; ++i){
  5.             for (int j = 0; j < n; ++j) {
  6.                 ans[i][j] = Math.sin((double) (i*i-j*j)/n);
  7.                 if (ans[i][j] > 0) {
  8.                     counter++;
  9.                 }
  10.             }
  11.         }
  12.         System.out.println("Amount of positive elements: " + counter);
  13.         return ans;
  14.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement