解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class C1468 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { F(sc.nextInt(), sc.nextInt()); } sc.close(); } private static final String[] dict = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty" }; private static final String[] dictTen = {"twenty", "thirty", "forty", "fifty"}; private static void F(int h, int m){ StringBuffer sb = new StringBuffer(); //小时 if(h >= 0 && h <= 20){ sb.append(dict[h]+" "); }else{ sb.append("twenty " + dict[h%10] + " "); } //分钟 if(m == 0){ sb.append("o'clock"); }else if(m >= 0 && m <= 20){ sb.append(dict[m]); }else if(m % 10 == 0){ sb.append(dictTen[m-2]); }else{ sb.append(dictTen[m/10-2]+" ").append(dict[m%10]); } System.out.println(sb); } }
0.0分
0 人评分
C二级辅导-求偶数和 (C语言代码)浏览:632 |
点我有惊喜!你懂得!浏览:1392 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:488 |
简单的a+b (C语言代码)浏览:583 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:783 |
最长单词 (C语言代码)浏览:1474 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:593 |
K-进制数 (C语言描述,蓝桥杯)浏览:955 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:727 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:742 |