shivamisone

verticle printing

Oct 11th, 2023
1,039
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | Source Code | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class teambanner {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         System.out.println("enter the number of teams");
  7.         String n1 = sc.nextLine();
  8.         int n = Integer.parseInt(n1);
  9.         String[] t = new String[n];
  10.         int size[] = new int[n];
  11.         System.out.println("enter team names");
  12.         for (int i = 0; i < t.length; i++) {
  13.             System.out.print("team" + (i + 1) + ":");
  14.             t[i] = sc.nextLine();
  15.             size[i] = t[i].length();
  16.             System.out.println("");
  17.         }
  18.         int large = 0;
  19.  
  20.         for (int i = 0; i < size.length - 1; i++) {
  21.             if (size[i] > size[i + 1]) {
  22.                 large = size[i];
  23.             }
  24.         }
  25.         for (int i = 0; i < large; i++) {
  26.             for (int j = 0; j < t.length; j++) {
  27.                 try {
  28.                     System.out.print(t[j].charAt(i) + "   ");
  29.                 } catch (Exception e) {
  30.                     System.out.print("    ");
  31.                     continue;
  32.                 }
  33.             }
  34.             System.out.println("");
  35.         }
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment