We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8ac0ac6 commit 180a3e8Copy full SHA for 180a3e8
Nested loop
@@ -89,3 +89,31 @@ public class Main
89
System.out.println(count);
90
}
91
92
+ // REVERSE OF AN ARRAY
93
+
94
+ import java.util.*;
95
+public class Main
96
+{
97
+ public static void main(String[] args) {
98
+ Scanner sc = new Scanner(System.in);
99
+ int n =sc.nextInt();
100
+ int a[] = new int[n];
101
+ for(int i=0;i<n;i++){
102
+ a[i]=sc.nextInt();
103
104
+ }
105
+ int temp =0;
106
+ for(int i=0;i<n/2;i++){
107
+ temp = a[i];
108
+ a[i] =a[n-1-i];
109
+ a[n-1-i]=temp;
110
111
112
113
114
+ System.out.print(a[i]+" ");
115
116
117
118
+}
119
0 commit comments