Java—Time 傷城~ 2022-12-13 04:19 140阅读 0赞 ## Java—Time ## Description Digital clock use 4 digits to express time, each digit is described by 3\*3 characters (including”|”,”\_”and” “).now given the current time, please tell us how can it be expressed by the digital clock. Input There are several test cases. Each case contains 4 integers in a line, separated by space. Proceed to the end of file. Output For each test case, output the time expressed by the digital clock such as Sample Output. Sample Input 1 2 5 6 2 3 4 2 Output ![在这里插入图片描述][20201009221545170.png_pic_center] import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner reader = new Scanner(System.in); int i; while(reader.hasNext()) { int s[]=new int [10]; for(i=0;i<4;i++) { s[i]=reader.nextInt(); } for(i=0;i<4;i++) { if(s[i]==0) System.out.print(" "+"_"+" "); else if(s[i]==1) System.out.print(" "+" "+" "); else if(s[i]==2) System.out.print(" "+"_"+" "); else if(s[i]==3) System.out.print(" "+"_"+" "); else if(s[i]==4) System.out.print(" "+" "+" "); else if(s[i]==5) System.out.print(" "+"_"+" "); else if(s[i]==6) System.out.print(" "+"_"+" "); else if(s[i]==7) System.out.print(" "+"_"+" "); else if(s[i]==8) System.out.print(" "+"_"+" "); else if(s[i]==9) System.out.print(" "+"_"+" "); } System.out.println(); for(i=0;i<4;i++) { if(s[i]==0) System.out.print("|"+" "+"|"); else if(s[i]==1) System.out.print(" "+" "+"|"); else if(s[i]==2) System.out.print(" "+"_"+"|"); else if(s[i]==3) System.out.print(" "+"_"+"|"); else if(s[i]==4) System.out.print("|"+"_"+"|"); else if(s[i]==5) System.out.print("|"+"_"+" "); else if(s[i]==6) System.out.print("|"+"_"+" "); else if(s[i]==7) System.out.print(" "+" "+"|"); else if(s[i]==8) System.out.print("|"+"_"+"|"); else if(s[i]==9) System.out.print("|"+"_"+"|"); } System.out.println(); for(i=0;i<4;i++) { if(s[i]==0) System.out.print("|"+"_"+"|"); else if(s[i]==1) System.out.print(" "+" "+"|"); else if(s[i]==2) System.out.print("|"+"_"+" "); else if(s[i]==3) System.out.print(" "+"_"+"|"); else if(s[i]==4) System.out.print(" "+" "+"|"); else if(s[i]==5) System.out.print(" "+"_"+"|"); else if(s[i]==6) System.out.print("|"+"_"+"|"); else if(s[i]==7) System.out.print(" "+" "+"|"); else if(s[i]==8) System.out.print("|"+"_"+"|"); else if(s[i]==9) System.out.print(" "+"_"+"|"); } System.out.println(); } } } [20201009221545170.png_pic_center]: /images/20221123/d00926922cc24143b2d923456d5a89eb.png
还没有评论,来说两句吧...