Created
April 24, 2017 04:35
-
-
Save AstroRokit/d40a632a0296c32726572be7ea99568e to your computer and use it in GitHub Desktop.
fuck big-o notaion
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
//Gino Di Gregorio | |
import java.util.*; | |
import java.util.Scanner; | |
import java.util.Arrays; | |
import java.util.Stack; | |
public class ArrayReverse { | |
static Scanner scan = new Scanner(System.in); | |
public static void main(String[] args){ | |
System.out.println("Please enter length of Array"); | |
int size = scan.nextInt(); | |
int anArray[] = new int[size]; | |
for(int i = 0; i < size; i++){ | |
System.out.println("Please enter array value"); | |
anArray[i] = scan.nextInt(); | |
} | |
reverser(anArray); | |
} | |
public static void reverser(int[] anArray){ | |
Stack<Integer> arrayValues = new Stack<Integer>(); | |
for(int i = 0; i < anArray.length; i++){ | |
arrayValues.push(anArray[i]); | |
} | |
for(int i = 0; i < anArray.length; i++){ | |
anArray[i] = arrayValues.pop(); | |
} | |
printArray(anArray); | |
} | |
private static void printArray(int[] anArray){ | |
System.out.println(Arrays.toString(anArray)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment