-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask52.java
More file actions
38 lines (30 loc) · 1.22 KB
/
Copy pathTask52.java
File metadata and controls
38 lines (30 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package HomeWork;
import java.util.Scanner;
/**
* Created by lelyi4ka on 02.06.15.
*/
public class Task52 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Введите длину массива ");
try {
int n = in.nextInt();
int[] arr = new int[n];
System.out.println("Заполните массив из " + n + " элементов");
for (int i = 0; i < arr.length; i++) {
System.out.println("введите " + i + " элемент массива - ");
arr[i] = in.nextInt();
}
System.out.println("Получился массив:");
for (int element : arr) {
System.out.println(element);
}
System.out.println("Введите индекс необходимого Вам элемента массива:");
int i = in.nextInt();
System.out.println("Выбранный элемент массива равен: ");
System.out.println(arr[i]);
} catch (Exception e){
System.out.println("неправильный ввод");
}
}
}