-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwapVals.java
More file actions
28 lines (19 loc) · 746 Bytes
/
SwapVals.java
File metadata and controls
28 lines (19 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.io.*;
public class SwapVals {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
String[] inputValues = bufferedReader.readLine().split(" ");
int[] arr = new int[inputValues.length];
for (int i = 0; i < inputValues.length; i++) {
arr[i] = Integer.parseInt(inputValues[i]);
}
for (int x=0,j=arr.length -1; x<j; x++ ,j--) {
int temp = arr[x];
arr[x] = arr[j];
arr[j] = temp;
}
for (int k = 0; k < arr.length; k++) {
System.out.println("arr[" + k + "]= " + arr[k]);
}
}
}