Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class teambanner {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.println("enter the number of teams");
- String n1 = sc.nextLine();
- int n = Integer.parseInt(n1);
- String[] t = new String[n];
- int size[] = new int[n];
- System.out.println("enter team names");
- for (int i = 0; i < t.length; i++) {
- System.out.print("team" + (i + 1) + ":");
- t[i] = sc.nextLine();
- size[i] = t[i].length();
- System.out.println("");
- }
- int large = 0;
- for (int i = 0; i < size.length - 1; i++) {
- if (size[i] > size[i + 1]) {
- large = size[i];
- }
- }
- for (int i = 0; i < large; i++) {
- for (int j = 0; j < t.length; j++) {
- try {
- System.out.print(t[j].charAt(i) + " ");
- } catch (Exception e) {
- System.out.print(" ");
- continue;
- }
- }
- System.out.println("");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment