解题思路:暴力法
注意事项:
参考代码:
import java.util.Scanner; public class Main{ public static void main (String[] args){ Scanner in=new Scanner(System.in); String s[] ={"zero","one","two","three","four","five","six","seven","eight","nine","ten", "eleven", "twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen", "nineteen","twenty" }; String s2[]= {"thirty","forty","fifty"}; //计算时 while(in.hasNext()) { int h=in.nextInt(); int m=in.nextInt(); if(h<24&&m<60) { if(h<21) { System.out.print(s[h]+" "); } else { System.out.print(s[20]+" "+s[h%10]+" "); } } if(h<24&&m<60) { //计算分 if(m<=20&&m>0) { System.out.print(s[m]); } else if(m>20&&m<30){ System.out.print(s[20]+" "+s[m%10]); } else if(m==30) { System.out.print(s2[0]); } else if(m>30&&m<40) { System.out.print(s2[0]+" "+s[m%10]); } else if(m==40) { System.out.print(s2[1]); } else if(m>40&&m<50) { System.out.print(s2[1]+" "+s[m%10]); } else if(m==50) { System.out.print(s2[2]); } else if(m>50&&m<60) { System.out.print(s2[2]+" "+s[m%10]); } else{ System.out.print("o'clock"); } } } } }
0.0分
0 人评分