首页 > 代码库 > HW7.11

HW7.11

技术分享

技术分享

 

 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 between 0 and 511: "); 9         int number = input.nextInt();10 11         input.close();12 13         char[] chArray = Integer.toBinaryString(number).toCharArray();14         char[][] displayArray = new char[3][3];15 16         for(int i = 0; i < 3; i++)17         {18             for(int j = 0; j < 3; j++)19             {20                 displayArray[i][j] = chArray[i * 3 + 1];21                 if(displayArray[i][j] == ‘0‘)22                     System.out.print(‘H‘ + " ");23                 else24                     System.out.print(‘T‘ + " ");25             }26             System.out.println();27         }28     }29 }

 

HW7.11