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

Commit f8c66f3

Browse files
authored
Merge pull request #60 from Timmmmofey/features/lab1
Features/lab1
2 parents c588a36 + 4c7bf8a commit f8c66f3

File tree

8 files changed

+119
-0
lines changed

8 files changed

+119
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<module>students/23K0350</module>
3434
<module>students/23K0143</module>
3535
<module>students/23K0368</module>
36+
<module>students/23K1302</module>
3637
<module>students/23K0346</module>
3738
<module>students/24K0459</module>
3839
</modules>

students/0000001/A.java

Whitespace-only changes.

students/23K1302/23K1302-p01/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="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>23K1302</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K1302-p01</artifactId>
12+
<description>Массивы</description>
13+
</project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
public final class Main {
4+
5+
private Main() {
6+
7+
}
8+
9+
public static void main(String[] args) {
10+
System.out.println("первая практическая работа!");
11+
}
12+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package ru.mirea.practice.s0000001;
2+
3+
import java.util.Scanner;
4+
5+
public abstract class Pr1 {
6+
// Выполнил Мясников Тимофей КАБО-02-23
7+
public static void main(String[] args) {
8+
9+
int[] array = {1, 2, 3, 4, 5};
10+
int sum = 0;
11+
for (int value : array) {
12+
sum += value;
13+
}
14+
double average = (double) sum / array.length;
15+
System.out.println("Сумма: " + sum);
16+
System.out.println("Среднее арифметическое: " + average);
17+
18+
try (Scanner a = new Scanner(System.in)) { // Используем try-with-resources
19+
System.out.println("Введите размер массива:");
20+
int n = a.nextInt();
21+
int[] userArray = new int[n];
22+
System.out.println("Введите элементы массива:");
23+
for (int i = 0; i < n; i++) {
24+
userArray[i] = a.nextInt();
25+
}
26+
27+
sum = 0;
28+
int index = 0;
29+
do {
30+
sum += userArray[index];
31+
index++;
32+
} while (index < n);
33+
System.out.println("Сумма элементов (do-while): " + sum);
34+
35+
int min = userArray[0];
36+
int max = userArray[0];
37+
index = 1;
38+
while (index < n) {
39+
if (userArray[index] < min) {
40+
min = userArray[index];
41+
}
42+
if (userArray[index] > max) {
43+
max = userArray[index];
44+
}
45+
index++;
46+
}
47+
System.out.println("Минимальный элемент: " + min);
48+
System.out.println("Максимальный элемент: " + max);
49+
50+
System.out.println("Введите число для вычисления факториала:");
51+
int number = a.nextInt();
52+
System.out.println("Факториал " + number + " = " + factorial(number));
53+
}
54+
55+
System.out.println("Аргументы командной строки:");
56+
for (int i = 0; i < args.length; i++) {
57+
System.out.println("Аргумент " + (i + 1) + ": " + args[i]);
58+
}
59+
60+
System.out.println("Первые 10 чисел гармонического ряда:");
61+
for (int i = 1; i <= 10; i++) {
62+
System.out.printf("H%d = %.4f%n", i, 1.0 / i);
63+
}
64+
}
65+
66+
public static int factorial(int n) {
67+
int result = 1;
68+
for (int i = 1; i <= n; i++) {
69+
result *= i;
70+
}
71+
return result;
72+
}
73+
}

students/23K1302/A.java

Whitespace-only changes.

students/23K1302/README.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Мясников Тимофей
2+
КАБО-02-23

students/23K1302/pom.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>algorithms-and-data-structures</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K1302</artifactId>
12+
<packaging>pom</packaging>
13+
<description>Практическая работа Тимофея</description>
14+
15+
<modules>
16+
<module>23K1302-p01</module>
17+
</modules>
18+
</project>

0 commit comments

Comments
 (0)