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

Commit e0276f2

Browse files
Merge pull request #1 from DNLdmitrylavrischev/feuters/lab1
feuters/lab1
2 parents 03cb16f + 583bb22 commit e0276f2

File tree

69 files changed

+1776
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1776
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
<module>students/23K0505</module>
7373
<module>students/23K0359</module>
7474
<module>students/23K0688</module>
75+
<module>students/23K0355</module>
7576
<module>students/23K0215</module>
7677
<module>students/23K1167</module>
7778
<module>students/23K1226</module>

students/23K0355/23K0355-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: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>23K0355</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0355-p01</artifactId>
12+
<description>Практика№1 Лаврищев Д.Н.</description>
13+
</project>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package ru.mirea.practice.s0000001.task1;
2+
3+
import java.util.Scanner;
4+
5+
public abstract class Main {
6+
public static void main(String[] args) {
7+
try (Scanner input = new Scanner(System.in)) {
8+
System.out.print("Введите количестлво элементов: ");
9+
int count = input.nextInt();
10+
11+
int[] arr = new int[count];
12+
13+
System.out.println("Введите элементы:");
14+
for (int j = 0; j < count; j++) {
15+
arr[j] = input.nextInt();
16+
}
17+
18+
int total = 0;
19+
double average;
20+
21+
for (int value : arr) {
22+
total += value;
23+
}
24+
25+
average = (double) total / arr.length;
26+
27+
System.out.println("Сумма: " + total);
28+
System.out.println("Среднее: " + average);
29+
}
30+
}
31+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package ru.mirea.practice.s0000001.task2;
2+
3+
import java.util.Scanner;
4+
5+
public final class Mainn {
6+
7+
private Mainn() {}
8+
9+
public static void main(String[] args) {
10+
11+
try (Scanner scanner = new Scanner(System.in)) {
12+
System.out.print("Введите разгмер массива: ");
13+
int size = scanner.nextInt();
14+
15+
int[] numbers = new int[size];
16+
17+
System.out.println("Введите элементы массива:");
18+
for (int i = 0; i < size; i++) {
19+
numbers[i] = scanner.nextInt();
20+
}
21+
22+
int sum = 0;
23+
int i = 0;
24+
do {
25+
sum += numbers[i];
26+
i++;
27+
} while (i < size);
28+
29+
int max = numbers[0];
30+
int min = numbers[0];
31+
i = 1;
32+
while (i < size) {
33+
if (numbers[i] > max) {
34+
max = numbers[i];
35+
}
36+
if (numbers[i] < min) {
37+
min = numbers[i];
38+
}
39+
i++;
40+
}
41+
42+
System.out.println("Сумма элементов массива: " + sum);
43+
System.out.println("Максимальный элемент массива: " + max);
44+
System.out.println("Минимальный элемент массива: " + min);
45+
}
46+
}
47+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package ru.mirea.practice.s0000001.task3;
2+
3+
public final class Main {
4+
5+
private Main() {}
6+
7+
public static void main(String[] args) {
8+
int n = 10;
9+
10+
System.out.println("Первые " + n + " чисело гармонического ряда:");
11+
for (int i = 1; i <= n; i++) {
12+
double harmonicNumber = 1.0 / i;
13+
System.out.printf("H%d = %.4f%n", i, harmonicNumber);
14+
}
15+
}
16+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package ru.mirea.practice.s0000001.task4;
2+
3+
import java.util.Scanner;
4+
5+
public final class Main {
6+
7+
private Main() {}
8+
9+
public static long calculateFactorial(int number) {
10+
long factorial = 1;
11+
for (int i = 1; i <= number; i++) {
12+
factorial *= i;
13+
}
14+
return factorial;
15+
}
16+
17+
public static void main(String[] args) {
18+
19+
try (Scanner scanner = new Scanner(System.in)) {
20+
21+
System.out.print("Введите число длоя вычисления его факториала: ");
22+
int number = scanner.nextInt();
23+
24+
long result = calculateFactorial(number);
25+
26+
System.out.println("Факториал числа " + number + " равен " + result);
27+
}
28+
}
29+
}

students/23K0355/23K0355-p02/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>23K0355</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0355-p02</artifactId>
12+
<description>Практика№2 Лаврищев Д.Н.</description>
13+
</project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package ru.mirea.practice.s0000001.task1.task1.task1;
2+
3+
public class Circle {
4+
private Point center;
5+
private double radius;
6+
7+
public Circle(Point center, double radius) {
8+
this.center = center;
9+
this.radius = radius;
10+
}
11+
12+
public Point getCenter() {
13+
return center;
14+
}
15+
16+
public double getRadius() {
17+
return radius;
18+
}
19+
20+
@Override
21+
public String toString() {
22+
return "Круг(центр: " + center + ", радиус: " + radius + ")";
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package ru.mirea.practice.s0000001.task1.task1.task1;
2+
3+
public class Point {
4+
private double x;
5+
private double y;
6+
7+
public Point(double x, double y) {
8+
this.x = x;
9+
this.y = y;
10+
}
11+
12+
public double getX() {
13+
return x;
14+
}
15+
16+
public double getY() {
17+
return y;
18+
}
19+
20+
@Override
21+
public String toString() {
22+
return "Точка(" + x + ", " + y + ")";
23+
}
24+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package ru.mirea.practice.s0000001.task1.task1.task1;
2+
3+
import java.util.Scanner;
4+
5+
public class Tester {
6+
private Circle[] circles;
7+
private int count;
8+
9+
public Tester(int size) {
10+
circles = new Circle[size];
11+
count = 0;
12+
}
13+
14+
public void addCircle(Circle circle) {
15+
if (count < circles.length) {
16+
circles[count] = circle;
17+
count++;
18+
} else {
19+
System.out.println("Массив заполнен. Не удается добавить больше кружочков.");
20+
}
21+
}
22+
23+
public void printCircles() {
24+
for (int i = 0; i < count; i++) {
25+
System.out.println(circles[i]);
26+
}
27+
}
28+
29+
public int getCount() {
30+
return count;
31+
}
32+
33+
public static void main(String[] args) {
34+
try (Scanner scanner = new Scanner(System.in)) {
35+
Tester tester = new Tester(3);
36+
37+
for (int i = 0; i < 3; i++) {
38+
System.out.println("Введите координату x для центра окружности " + (i + 1) + ": ");
39+
double x = scanner.nextDouble();
40+
System.out.println("Введите координату y для центра окружности " + (i + 1) + ": ");
41+
double y = scanner.nextDouble();
42+
System.out.println("Введите радиус окружности " + (i + 1) + ": ");
43+
double radius = scanner.nextDouble();
44+
45+
tester.addCircle(new Circle(new Point(x, y), radius));
46+
}
47+
48+
tester.printCircles();
49+
System.out.println("Общее количество кругов: " + tester.getCount());
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)