From c48d765647b41788c16718e9e307b8726c43b759 Mon Sep 17 00:00:00 2001 From: Suzik123 Date: Wed, 8 Mar 2023 09:16:53 +0200 Subject: [PATCH 1/3] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lab2/Main.java | 62 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/lab2/Main.java diff --git a/src/lab2/Main.java b/src/lab2/Main.java new file mode 100644 index 0000000..e6c0423 --- /dev/null +++ b/src/lab2/Main.java @@ -0,0 +1,62 @@ +package lab2; + +import java.util.InputMismatchException; +import java.util.Scanner; + +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); + } +} From 4fbc82ec5dbfbcf55e8e398f159dd7c536d5e6dd Mon Sep 17 00:00:00 2001 From: Suzik123 Date: Fri, 31 Mar 2023 21:57:56 +0300 Subject: [PATCH 2/3] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/modules.xml | 1 + laba3/laba3.iml | 11 +++++++++++ laba3/src/Main.java | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 laba3/laba3.iml create mode 100644 laba3/src/Main.java diff --git a/.idea/modules.xml b/.idea/modules.xml index e7763c5..e64ce87 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,6 +3,7 @@ + \ No newline at end of file diff --git a/laba3/laba3.iml b/laba3/laba3.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/laba3/laba3.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/laba3/src/Main.java b/laba3/src/Main.java new file mode 100644 index 0000000..3e59c38 --- /dev/null +++ b/laba3/src/Main.java @@ -0,0 +1,5 @@ +public class Main { + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} \ No newline at end of file From 02850e7edb6c74182d7d0e97702cd57abd02c691 Mon Sep 17 00:00:00 2001 From: Suzik123 Date: Sat, 1 Apr 2023 19:13:24 +0300 Subject: [PATCH 3/3] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- laba3/src/Main.java | 90 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) diff --git a/laba3/src/Main.java b/laba3/src/Main.java index 3e59c38..0b80dc5 100644 --- a/laba3/src/Main.java +++ b/laba3/src/Main.java @@ -1,5 +1,93 @@ +import java.util.Scanner; +import java.util.ArrayList; +import java.util.Collections; public class Main { public static void main(String[] args) { - System.out.println("Hello world!"); + System.out.println("Введіть текст:"); + Scanner scan = new Scanner(System.in); + String inputText = scan.nextLine(); + StringBuilder text = new StringBuilder(inputText); + StringBuilder suz = new StringBuilder(); + while (true){ + if(text.isEmpty()){ + break; + } + int index1 = text.indexOf("."); + int index2 = text.indexOf("!"); + + int index3 = text.indexOf("?"); + + int index4 = text.indexOf("..."); + + int[] array1= {index1, index2, index3, index4}; + ArrayList list = new ArrayList(); + for (int i = 0; i < array1.length; i++) { + if (array1[i] >= 0) { + list.add(array1[i]); + } + } + int min = Collections.min(list); + String rechennya1 = text.substring(0, min); + System.out.println(rechennya1); + if (rechennya1.contains(" ")){ + StringBuilder rechennya = new StringBuilder(rechennya1); + String firstword1; + String secondword1 = text.substring(rechennya.lastIndexOf(" ")+1, rechennya.length()); + String secondword2; + secondword2 = secondword1.substring(0, 1).toUpperCase()+secondword1.substring(1, secondword1.length()); + StringBuilder secondword = new StringBuilder(secondword2); + if(rechennya.charAt(rechennya.indexOf(" ")-1)==','){ + firstword1 = text.substring(0, rechennya.indexOf(" ")-1); + secondword.append(","); + } + else { + firstword1 = text.substring(0, rechennya.indexOf(" ")); + } + + String firstword2 = firstword1.substring(0, 1).toLowerCase()+firstword1.substring(1, firstword1.length()); + StringBuilder firstword = new StringBuilder(firstword2); + + + firstword.insert(0, " "); + rechennya.delete(0, rechennya.indexOf(" ")); + rechennya.insert(0, secondword); + rechennya.delete(rechennya.lastIndexOf(" "), rechennya.length()); + rechennya.append(firstword); + if ((index1==index4)&&(index1==min)){ + rechennya.append(text.substring(min, min+3)); + rechennya.append(" "); + text.delete(0, min+4); + } + else { + rechennya.append(text.substring(min, min+1)); + rechennya.append(" "); + text.delete(0, min+2); + } + suz.append(rechennya); + } + else { + StringBuilder rechennya = new StringBuilder(rechennya1); + if ((index1==index4)&&(index1==min)){ + rechennya.append(text.substring(min, min+3)); + rechennya.append(" "); + text.delete(0, min+4); + } + else { + rechennya.append(text.substring(min, min+1)); + rechennya.append(" "); + text.delete(0, min+2); + } + suz.append(rechennya); + } + + + + + + + + + } + System.out.println(suz); } } \ No newline at end of file