fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. }
  14. }public class Main {
  15. public static void main(String[] args) {
  16. // Исходные данные
  17. int d = 2;
  18. double a = 3.5;
  19. int x = 3;
  20. int i = 2;
  21.  
  22. // Проходим по всем значениям j и вычисляем Z
  23. int[] jValues = {1, 2, 4, 5, 6, 7, 8};
  24. for (int j : jValues) {
  25. double Z;
  26. if (j == 1 || j == 2 || j == 4 || j == 8) {
  27. Z = 1 + d * Math.sin(d / a * (i - 1) * i) + a * Math.pow(i, 2) + 2 / (3.0 * x);
  28. } else if (j == 5 || j == 6 || j == 7) {
  29. Z = Math.pow(1 + d * Math.sin(d / a * (i - 1) * i) + a * Math.pow(i, 2) + 2 / (3.0 * x), 2);
  30. } else {
  31. System.out.println("Некорректное значение j: " + j);
  32. continue; // Переходим к следующей итерации цикла
  33. }
  34. System.out.println("Значение Z при i=" + i + ", j=" + j + ": " + Z);
  35. }
  36. }
  37. }
Success #stdin #stdout 0.1s 52680KB
stdin
1
stdout
Standard output is empty