Advertisement
RenSafaray

Untitled

May 2nd, 2024
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.94 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MyTaskk {
  4.  
  5.     public static void DoTaskk() {
  6.         Scanner sc = new Scanner(System.in);
  7.         System.out.println("Введите количество чисел: ");
  8.         int N = sc.nextInt();
  9.         int[] aiArray = new int[N];
  10.         int[] biArray = new int[N];
  11.         System.out.println("Введите числа:");
  12.         for (int i = 0; i < N; i++) {
  13.             aiArray[i] = sc.nextInt();
  14.         }
  15.         for (int i = 0; i < N; i++) {
  16.             int ai = aiArray[i];
  17.             if (ai % 2 == 0 && ai % 5 == 0) {
  18.                 biArray[i] = ai;
  19.             } else if (ai % 2 == 0) {
  20.                 biArray[i] = ai * ai;
  21.             } else if (ai % 5 == 0) {
  22.                 biArray[i] = ai * ai * ai;
  23.             } else {
  24.                 biArray[i] = 1 / ai;
  25.             }
  26.         }
  27.         System.out.println("Список bi:");
  28.         for (int i = 0; i < N; i++) {
  29.             System.out.println(biArray[i]);
  30.         }
  31.     }
  32.  
  33.     public void doTask() {
  34.         Scanner sc = new Scanner(System.in);
  35.         System.out.println("Введите количество чисел: ");
  36.         int N = sc.nextInt();
  37.         int[] aiArray = new int[N];
  38.         int[] biArray = new int[N];
  39.         System.out.println("Введите числа:");
  40.         for (int i = 0; i < N; i++) {
  41.             aiArray[i] = sc.nextInt();
  42.         }
  43.         for (int i = 0; i < N; i++) {
  44.             int ai = aiArray[i];
  45.             if (ai % 2 == 0 && ai % 5 == 0) {
  46.                 biArray[i] = ai;
  47.             } else if (ai % 2 == 0) {
  48.                 biArray[i] = ai * ai;
  49.             } else if (ai % 5 == 0) {
  50.                 biArray[i] = ai * ai * ai;
  51.             } else {
  52.                 biArray[i] = 1 / ai;
  53.             }
  54.         }
  55.         System.out.println("Список bi:");
  56.         for (int i = 0; i < N; i++) {
  57.             System.out.println(biArray[i]);
  58.         }
  59.     }
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement