解题思路:
注意事项:
参考代码:
import java.io.BufferedInputStream; import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(new BufferedInputStream(System.in)); int h = scanner.nextInt(),m = scanner.nextInt(); String sn[] = {"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven" ,"twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen" ,"twenty"}; String snn[] = {"thirty","forty","fifty"};//这个数组是把20,30,40,50放在里面, if(m != 0){ //先判断h if(h > 20){ System.out.print("twenty"+" "+sn[h%10]+" "); } else { System.out.print(sn[h]+" "); } //再判断m //用m%10判断个位是否为0 if(m%10 == 0){ if(m > 20){ System.out.print(snn[m/10-3]); } else { System.out.print(sn[m]); } } else{ if(m > 20){ System.out.print(snn[m/10-2]+" "+sn[m%10]); } else { System.out.print(sn[m]); } } } else { if(h > 20){ System.out.print("twenty"+" "+sn[h%10]+"o'clock"); } else { System.out.print(sn[h]+" "+"o'clock"); } } } }
0.0分
0 人评分