Skip to content

Commit 90d1fc1

Browse files
committed
2 Array's Problems Solved
0 parents  commit 90d1fc1

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

Array/Printing Reverse Array.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import java.util.*;
2+
3+
class TestClass {
4+
public static void main(String args[] ) throws Exception {
5+
Scanner sc = new Scanner(System.in);
6+
int n = sc.nextInt();
7+
int a[] = new int[n];
8+
for (int i = 0; i < n; i++) {
9+
a[i] = sc.nextInt();
10+
}
11+
for (int i = n - 1; i >= 0; i--) {
12+
System.out.println(a[i]);
13+
}
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import java.util.*;
2+
class TestClass {
3+
public static void main(String args[] ) throws Exception {
4+
Scanner sc = new Scanner(System.in);
5+
int r = sc.nextInt();
6+
int c = sc.nextInt();
7+
int a[][] = new int[r][c];
8+
for (int i = 0; i < r; i++) {
9+
for (int j = 0; j < c; j++) {
10+
a[i][j] = sc.nextInt();
11+
}
12+
}
13+
for (int i = 0; i < c; i++) {
14+
for (int j = 0; j < r; j++) {
15+
System.out.print(a[j][i] + " ");
16+
}
17+
System.out.println();
18+
}
19+
}
20+
21+
}

0 commit comments

Comments
 (0)