This repository was archived by the owner on Mar 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
48 lines (36 loc) · 1.46 KB
/
Main.java
File metadata and controls
48 lines (36 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.Random;
public class Main {
public static void main(String[] args) {
// Массив w: нечётные числа от 15 до 5 по убыванию
int[] w = {15, 13, 11, 9, 7, 5};
// Массив x: 15 случайных чисел в диапазоне [-13.0 ; 4.0]
float[] x = new float[15];
Random random = new Random();
for (int i = 0; i < x.length; i++) {
x[i] = -13 + random.nextFloat() * (4 - (-13));
}
// Двумерный массив f 6x15
double[][] f = new double[6][15];
for (int i = 0; i < w.length; i++) {
for (int j = 0; j < x.length; j++) {
double valueX = x[j];
if (w[i] == 15) {
f[i][j] = Math.sin(Math.atan(Math.cos(valueX)));
} else if (w[i] == 7 || w[i] == 9 || w[i] == 13) {
f[i][j] = 4 * Math.log(Math.sqrt(Math.abs(valueX)));
} else {
f[i][j] = Math.asin(
Math.pow(Math.cos(Math.cbrt(3.0 / valueX)), 2)
);
}
}
}
// Вывод массива с 5 знаками после запятой
for (int i = 0; i < f.length; i++) {
for (int j = 0; j < f[i].length; j++) {
System.out.printf("%10.5f ", f[i][j]);
}
System.out.println();
}
}
}