Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in); // Объявляем Scanner
- System.out.println("Enter array length: ");
- int size = input.nextInt(); // Читаем с клавиатуры размер массива и записываем в size
- int array[] = new int[size]; // Создаём массив int размером в size
- System.out.println("Insert array elements:");
- /*Пройдёмся по всему массиву, заполняя его*/
- for (int i = 0; i < size; i++) {
- array[i] = input.nextInt(); // Заполняем массив элементами, введёнными с клавиатуры
- }
- System.out.print ("Inserted array elements:");
- for (int i = 0; i < size; i++) {
- System.out.print (" " + array[i]); // Выводим на экран, полученный массив
- }
- System.out.println();
- }
- public static void main(String[] agrs)
- {
- int[] a = new int[7];
- int i = 0;
- Scanner in = new Scanner(System.in);
- for (int element : a)
- {
- System.out.print("Введите " + (i + 1) + "-й элемент массива: ");
- a[i] = in.nextInt();
- System.out.println(a[i] + " - ");
- i++;
- }
- for (int element : a)
- System.out.print(element + " ");
- }
- public static void main(String[] agrs)
- {
- int[] a = new int[7];
- int i = 0;
- Scanner in = new Scanner(System.in);
- for (int element : a)
- {
- System.out.print("Введите " + (i + 1) + "-й элемент массива: ");
- a[i] = in.nextInt();
- System.out.println(a[i] + " - ");
- i++;
- }
- System.out.println(Arrays.toString(a));
- }
- import java.util.Scanner;
- public class PerBor_Mas {
- public static void main(String[] args) throws InterruptedException {
- int n = vvod.nextInt();
- int[] A = new int[n];
- int k = vvod.nextInt();
- Scanner vvod = new Scanner(System.in);
- System.out.println("Введите длину одномерного массива");
- System.out.println("Введите первый элемент массива");
- System.out.println("Водится массив");
- for (int i = 0; i < n; i++) {
- System.out.print(A[i] + k + "t");
- k++;
- }
- System.out.println(" ");
- }
- }
Add Comment
Please, Sign In to add comment