Advertisement
SIRAKOV4444

Untitled

May 26th, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class Lab {
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. String[] input = scanner.nextLine().split(", ");
  9. int size = Integer.parseInt(input[0]);
  10. String type = input[1];
  11. int[][] matrix = new int[size][size];
  12. int num = 1;
  13.  
  14.  
  15. if (type.equals("A")) {
  16. for (int col = 0; col < size; col++) {
  17. for (int rol = 1; rol <size; rol++) {
  18. matrix[rol][col] = num;
  19. num++;
  20.  
  21.  
  22. }
  23.  
  24. }
  25. //} else if (type.equals("B")) {
  26.  
  27. }
  28. for(int rows=0;rows<matrix.length;rows++){
  29.  
  30. for(int cols=0;cols<matrix[rows].length;cols++){
  31. System.out.print(matrix[rows][cols]+" ");
  32. }
  33. System.out.println();
  34. }
  35.  
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement