From 8b52d689ea4f7c2b56c7cda4226226cbaf46c6b8 Mon Sep 17 00:00:00 2001 From: Suzik123 Date: Thu, 2 Mar 2023 16:30:54 +0200 Subject: [PATCH] Laba --- .idea/.gitignore | 8 +++++ .idea/misc.xml | 6 ++++ .idea/modules.xml | 8 +++++ .idea/vcs.xml | 6 ++++ lab1.iml | 11 ++++++ out/production/lab1/Main.class | Bin 0 -> 2317 bytes src/Main.java | 60 +++++++++++++++++++++++++++++++++ 7 files changed, 99 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 lab1.iml create mode 100644 out/production/lab1/Main.class create mode 100644 src/Main.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..03f397c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e7763c5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lab1.iml b/lab1.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/lab1.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/lab1/Main.class b/out/production/lab1/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..399899ec590a77b25f2bf3b6da300a1a2a13af96 GIT binary patch literal 2317 zcmbVOTWl0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B<&w761SM literal 0 HcmV?d00001 diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..5993553 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,60 @@ +import java.util.Scanner; +import java.util.InputMismatchException; + +public class Main { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + System.out.println("Введіть значення n:"); + double n = 0; + try { + n = scan.nextDouble(); + } catch (InputMismatchException e) { + System.out.println("Число введене не вірно"); + System.exit(0); + } + System.out.println("Введіть значення m:"); + double m = 0; + try { + m = scan.nextDouble(); + } catch (InputMismatchException e) { + System.out.println("Число введене не вірно"); + System.exit(0); + } + + System.out.println("Введіть значення a:"); + double a = 0; + try { + a = scan.nextDouble(); + } catch (InputMismatchException e) { + System.out.println("Число введене не вірно"); + System.exit(0); + } + System.out.println("Введіть значення b:"); + double b = 0; + try { + b = scan.nextDouble(); + } catch (InputMismatchException e) { + System.out.println("Число введене не вірно"); + System.exit(0); + } + if (a > n) { + System.out.println("Значення n має бути більшим або рівним a"); + System.exit(0); + } + if (b > m) { + System.out.println("Значення m має бути більшим або рівним b"); + System.exit(0); + } + double s1 = 0; + double s2 = 0; + + for (double i = a; i <= n; i++) { + for (double j = b; j <= m; j++){ + // оскільки C дорівнює 0, то можна скоротити i + s1=s1+(1/j); + } + s2=s2+s1; + } + System.out.println("Результат:" + s2); + } +}