Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ChangePositionArray {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = Integer.parseInt(sc.nextLine());
- char temp = ' ';
- char[] word = new char[n];
- for (int i = 0; i < word.length; i++) {
- word[i] = sc.next().charAt(0);
- }
- for (int i = 0; i < word.length - 1; i++) {
- temp = word[i];
- word[i] = word[word.length - 1 - i];
- word[word.length - 1 - i] = temp;
- if (i == word.length / 2 - 1) {
- break;
- }
- }
- System.out.println(word);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement