Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.school;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int arr[] = new int[10];
- for (int i = 0; i < 9; i++) arr[i] = in.nextInt();
- for (int i = 0; i < 9; i++) System.out.print(arr[i] + " ; ");
- System.out.println("");
- System.out.println("Give me index of your number");
- int index = in.nextInt();
- System.out.println("Give me value of your number");
- int value = in.nextInt();
- for (int i = 9; i > index; i--) // Переносим все элементы после точки вставки на один вперед
- arr[i] = arr[i - 1];
- arr[index] = value; // Вставляем
- for (int i = 0; i < 10; i++) System.out.print(arr[i] + " ; ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement