Created
January 29, 2014 14:55
-
-
Save JorgeOlvera/8689693 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import java.util.Scanner; | |
import java.io.*; | |
public class arrayReverser { | |
public static void main(String [] args) { | |
Scanner input = new Scanner(System.in); | |
int [] arrayA | |
= new int [5]; | |
int [] array2 = new int [5]; | |
for (int a=0; a<5; a++) { | |
arrayA | |
[a] = input.nextInt(); | |
} | |
array2 = reverseArray(arrayA); | |
System.out.println(array2[0] + " " + array2[1] + " " + array2[2] + " " + array2[3] + " " + array2[4]); | |
} | |
public static int [] reverseArray(int [] arrayA) { | |
int [] array3 = new int [5]; | |
int c=5; | |
for (int b=0; b<5; b++) { | |
c=c-1; | |
array3[b] = arrayA[c]; | |
} | |
return array3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment