-
-
Save mariiaKolokolova/bf4fcbb95f9754cb1170741f2a740086 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package maricka.kolokolova; | |
import java.util.Arrays; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
// TODO Auto-generated method stub | |
System.out.println("Intup size of array:"); | |
Scanner sc = new Scanner(System.in); | |
int size; | |
size = sc.nextInt(); | |
int[] array = new int[size]; | |
for (int i = 0; i < size; i++) { | |
System.out.println("Input [" + i + "] elemtnt of array:"); | |
array[i] = sc.nextInt(); | |
} | |
System.out.println("Your array: " + Arrays.toString(array)); | |
int t; | |
for (int i = 0; i <= size / 2; i++) { | |
t = array[i]; | |
array[i] = array[size - 1 - i]; | |
array[size - 1 - i] = t; | |
} | |
System.out.println("New array: " + Arrays.toString(array)); | |
sc.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment