-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBanner.java
More file actions
39 lines (38 loc) · 1.19 KB
/
Copy pathBanner.java
File metadata and controls
39 lines (38 loc) · 1.19 KB
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
29
30
31
32
33
34
35
36
37
38
39
import java.io.*;
public class Banner {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a number");
int N = Integer.parseInt(br.readLine());
if (N < 3 || N > 8) {
System.out.println("INVALID INPUT");
System.exit(0);
}
String a[] = new String[N];
for (int i = 1; i <= N; i++) {
System.out.print("Team " + i + ":");
a[i - 1] = br.readLine();
}
String str = a[0];
int maxL = str.length();
for (int i = 0; i < N; i++) {
str = a[i];
int len = str.length();
if (maxL < len) {
maxL = len;
}
}
char a1[][] = new char[maxL][N];
for (int i = 0; i < maxL; i++) {
for (int j = 0; j < N; j++) {
String s = a[j];
if (i < s.length()) {
System.out.print(s.charAt(i) + "\t");
} else {
System.out.print(" \t");
}
}
System.out.println("");
}
}
}