We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a7904d6 commit 8e783c7Copy full SHA for 8e783c7
18.1 Reverse Array.java
@@ -50,3 +50,46 @@ public static void main(String[] args) {
50
51
}
52
53
+
54
+// other solutions
55
+import java.io.*;
56
57
+import java.util.*;
58
59
+public class Solution {
60
61
+public static void main(String[] args) {
62
63
+Scanner sc = new Scanner(System.in);
64
65
+int n = sc.nextInt();
66
67
+if(n<=0){
68
69
+return;
70
71
+}
72
73
+int[] ar = new int[n];
74
75
+int i = 0;
76
77
+while(sc.hasNextInt()){
78
79
+ar[i] = sc.nextInt();
80
81
+i++;
82
83
84
85
+int m = i;
86
87
+for(int j=m-1;j>=0;j--){
88
89
+System.out.print(ar[j]+" ");
90
91
92
93
94
95
0 commit comments