Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit dc304e3

Browse files
authored
Merge pull request #686 from Vika-Permyakova/main
Лабораторная 24-30
2 parents ac307db + afc0faf commit dc304e3

File tree

29 files changed

+927
-0
lines changed

29 files changed

+927
-0
lines changed

students/23K0364/23K0364-p25/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<artifactId>23K0364</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0364-p25</artifactId>
12+
<description>25 задание</description>
13+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
import java.util.Scanner;
4+
5+
public abstract class Task1 {
6+
public static void main(String[] args) {
7+
try (Scanner scanner = new Scanner(System.in)) {
8+
System.out.println("Введите строку:");
9+
String input = scanner.nextLine();
10+
System.out.println("Введите регулярное выражение для разбиения:");
11+
String regex = scanner.nextLine();
12+
String[] parts = input.split(regex);
13+
for (String part : parts) {
14+
System.out.println(part);
15+
}
16+
}
17+
}
18+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
import java.util.regex.Pattern;
4+
5+
public abstract class Task2 {
6+
public static void main(String[] args) {
7+
String regex = "^abcdefghijklmnopqrstuv18340$";
8+
String input1 = "abcdefghijklmnopqrstuv18340";
9+
String input2 = "abcdefghijklmnoasdfasdpqrstuv18340";
10+
11+
System.out.println(Pattern.matches(regex, input1)); // true
12+
System.out.println(Pattern.matches(regex, input2)); // false
13+
}
14+
}
15+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
import java.util.regex.Matcher;
4+
import java.util.regex.Pattern;
5+
6+
public abstract class Task3 {
7+
public static void main(String[] args) {
8+
String text = "Prices: 25.98 USD, 44 ERR, 0.004 EU, 100.50 RUV.";
9+
String regex = "\\b\\d+\\.\\d{2}\\s(USD|RUV|EU)\\b";
10+
Pattern pattern = Pattern.compile(regex);
11+
Matcher matcher = pattern.matcher(text);
12+
while (matcher.find()) {
13+
System.out.println("Found price: " + matcher.group());
14+
}
15+
}
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
import java.util.regex.Pattern;
4+
5+
public abstract class Task4 {
6+
public static void main(String[] args) {
7+
String text1 = "(1 + 8) – 9 / 4";
8+
String text2 = "6 / 5 – 2 * 9";
9+
String regex = "\\b\\d+(?!\\s*\\+)";
10+
11+
System.out.println("Text 1 contains numbers without +: " + Pattern.compile(regex).matcher(text1).find());
12+
System.out.println("Text 2 contains numbers without +: " + Pattern.compile(regex).matcher(text2).find());
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
import java.util.regex.Pattern;
4+
5+
public abstract class Task5 {
6+
public static void main(String[] args) {
7+
String regex = "^(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[0-2])/(19[0-9]{2}|[2-9][0-9]{3})$";
8+
String[] dates = {"29/02/2000", "30/04/2003", "01/01/2003", "29/02/2001", "30-04-2003", "1/1/1899"};
9+
10+
for (String date : dates) {
11+
System.out.println(date + " is valid: " + Pattern.matches(regex, date));
12+
}
13+
}
14+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
import java.util.regex.Pattern;
4+
5+
public abstract class Task6 {
6+
public static void main(String[] args) {
7+
String regex = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";
8+
String[] emails = {"user@example.com", "root@localhost", "myhost@@@com.ru", "@my.ru", "Julia String"};
9+
10+
for (String email : emails) {
11+
System.out.println(email + " is valid: " + Pattern.matches(regex, email));
12+
}
13+
}
14+
}
15+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
import java.util.regex.Pattern;
4+
5+
public abstract class Task7 {
6+
public static void main(String[] args) {
7+
String regex = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d_]{8,}$";
8+
String[] passwords = {"F032_Password", "TrySpy1", "smart_pass", "A007"};
9+
10+
for (String password : passwords) {
11+
System.out.println(password + " is valid: " + Pattern.matches(regex, password));
12+
}
13+
}
14+
}
15+

students/23K0364/23K0364-p26/pom.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<artifactId>23K0364</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0364-p26</artifactId>
12+
<description>26 задание</description>
13+
</project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
import java.util.Stack;
4+
5+
public abstract class Task1 {
6+
public static void reverseArray(int[] array) {
7+
Stack<Integer> stack = new Stack<>();
8+
for (int num : array) {
9+
stack.push(num);
10+
}
11+
for (int i = 0; i < array.length; i++) {
12+
array[i] = stack.pop();
13+
}
14+
}
15+
16+
public static void main(String[] args) {
17+
int[] array = {1, 2, 3, 4, 5};
18+
reverseArray(array);
19+
for (int num : array) {
20+
System.out.print(num + " ");
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)