Skip to content

Commit 180a3e8

Browse files
Update Nested loop
1 parent 8ac0ac6 commit 180a3e8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Nested loop

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,31 @@ public class Main
8989
System.out.println(count);
9090
}
9191
}
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+
for(int i=0;i<n;i++){
114+
System.out.print(a[i]+" ");
115+
}
116+
117+
}
118+
}
119+

0 commit comments

Comments
 (0)