lr13 -> task_2 -> e1-e3

This commit is contained in:
2026-05-23 17:20:02 +05:00
parent 7c4e17e1b1
commit 5571032ca4
3 changed files with 113 additions and 0 deletions

41
lr13/task_2/e2.java Normal file
View File

@@ -0,0 +1,41 @@
package lr13.task_2;
import java.util.*;
public class e2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
try {
System.out.print("Введите строки и столбцы: ");
int n = sc.nextInt();
int m = sc.nextInt();
int[][] a = new int[n][m];
System.out.println("Введите матрицу:");
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i][j] = sc.nextInt();
}
}
System.out.print("Введите номер столбца: ");
int col = sc.nextInt();
System.out.println("Столбец:");
for (int i = 0; i < n; i++) {
System.out.println(a[i][col]);
}
} catch (InputMismatchException e) {
System.out.println("Ошибка: введена строка вместо числа");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("Ошибка: нет такого столбца");
} finally {
System.out.println("Работа завершена");
}
}
}