1 import java.util.Scanner; 2 3 public class Solution 4 { 5 public static void main(String[] args) 6 { 7 Scanner input = new Scanner(System.in); 8 System.out.print("Enter a number: "); 9 int number = input.nextInt(); 10 11 input.close(); 12 13 printMatrix(number); 14 } 15 16 public static void printMatrix(int n) 17 { 18 for(int i = 0; i < n; i++) 19 { 20 for(int j = 0; j < n; j++) 21 System.out.print((int)(Math.random() * 2) + " "); 22 System.out.println(); 23 } 24 } 25 }
时间: 2024-11-07 14:14:41