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

Commit f4ce32b

Browse files
committed
Лабораторная №1 и №2
1 parent b917e7d commit f4ce32b

File tree

16 files changed

+313
-0
lines changed

16 files changed

+313
-0
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<module>students/24K0459</module>
4343
<module>students/23K0364</module>
4444
<module>students/23K0155</module>
45+
<module>students/23K0089</module>
4546
</modules>
4647

4748
<dependencies>

students/23K0089/23K0089-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>23K0089</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0089-p01</artifactId>
12+
<description>Массивы</description>
13+
</project>
Binary file not shown.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package ru.mirea.practice.s23k0089.task3;
2+
3+
import java.util.Arrays;
4+
5+
public abstract class Main {
6+
public static void main(String[] args) {
7+
System.out.println("Задание №3");
8+
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
9+
System.out.println(Arrays.toString(arr));
10+
float sr = 0f;
11+
System.out.println(sr);
12+
for (int i = 0; i < 10; i++) {
13+
sr += arr[i];
14+
}
15+
System.out.println("Сумма всех элементов массива: " + Float.toString(sr));
16+
sr /= arr.length;
17+
System.out.println("Среднее арифметическое элементов массива: " + Float.toString(sr));
18+
}
19+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package ru.mirea.practice.s23k0089.task4;
2+
3+
import java.util.Arrays;
4+
import java.util.Scanner;
5+
6+
public abstract class Main {
7+
public static void main(String[] args) {
8+
try (Scanner sc = new Scanner(System.in)) {
9+
System.out.println("Задание №4");
10+
int[] arr1 = new int[5];
11+
int i = 0;
12+
float sum1 = 0f;
13+
while (i != 5) {
14+
System.out.println("Введите ещё значения в количестве " + (5 - i));
15+
arr1[i] = sc.nextInt();
16+
sum1 += arr1[i];
17+
i++;
18+
}
19+
int max = arr1[0];
20+
int min = arr1[0];
21+
for (i = 1; i < arr1.length; i++) {
22+
if (max < arr1[i]) {
23+
max = arr1[i];
24+
}
25+
if (min > arr1[i]) {
26+
min = arr1[i];
27+
}
28+
}
29+
System.out.println(Arrays.toString(arr1));
30+
System.out.println("max = " + max + "\nmin = " + min);
31+
int[] arr2 = new int[5];
32+
i = 0;
33+
float sum2 = 0f;
34+
do {
35+
System.out.println("Введите ещё значения в количестве " + (5 - i));
36+
arr2[i] = sc.nextInt();
37+
sum2 += arr2[i];
38+
i++;
39+
} while (i != 5);
40+
max = arr2[0];
41+
min = arr2[0];
42+
for (i = 1; i < arr2.length; i++) {
43+
if (max < arr2[i]) {
44+
max = arr2[i];
45+
}
46+
if (min > arr2[i]) {
47+
min = arr2[i];
48+
}
49+
}
50+
System.out.println(Arrays.toString(arr2));
51+
System.out.println("max = " + max + "\nmin = " + min);
52+
System.out.println("Сумма элементов I: " + Float.toString(sum1) + "\nСумма элементов II: " + Float.toString(sum2));
53+
}
54+
}
55+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package ru.mirea.practice.s23k0089.task5;
2+
3+
import java.util.Arrays;
4+
5+
public abstract class Main {
6+
public static void main(String[] args) {
7+
for (String arg : args) {
8+
System.out.printf(arg);
9+
}
10+
System.out.println(Arrays.toString(args));
11+
}
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package ru.mirea.practice.s23k0089.task6;
2+
3+
public abstract class Main {
4+
public static void main(String[] args) {
5+
float an = 0;
6+
for (int i = 1; i < 11; i++) {
7+
an += 1 / (float) i;
8+
for (int j = 1; j < i; j++) {
9+
System.out.printf("1/%d + ", j);
10+
}
11+
System.out.printf("1/%d = %f\n", i, an);
12+
}
13+
}
14+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ru.mirea.practice.s23k0089.task7;
2+
3+
public abstract class Factorial {
4+
public static int factorial(int n) {
5+
int answer = 1;
6+
for (int i = 2; i <= n; i++) {
7+
answer *= i;
8+
}
9+
return answer;
10+
}
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package ru.mirea.practice.s23k0089.task7;
2+
3+
import java.util.Scanner;
4+
5+
public abstract class Main {
6+
public static void main(String[] args) {
7+
try (Scanner sc = new Scanner(System.in)) {
8+
int n = sc.nextInt();
9+
for (int i = 1; i < n + 1; i++) {
10+
System.out.printf("%d! = %d\n", i, Factorial.factorial(i));
11+
}
12+
}
13+
}
14+
}

students/23K0089/23K0089-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="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>23K0089</artifactId>
7+
<groupId>ru.mirea.practice</groupId>
8+
<version>2024.1</version>
9+
<relativePath>../pom.xml</relativePath>
10+
</parent>
11+
<artifactId>23K0089-p02</artifactId>
12+
<description>Массивы</description>
13+
</project>

0 commit comments

Comments
 (0)