解题思路:
注意事项:
参考代码:
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语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:584 |
不容易系列 (C语言代码)浏览:668 |
printf基础练习2 (C语言代码)浏览:942 |
数组输出 (C语言代码)错误???浏览:565 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:751 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:965 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:686 |
用筛法求之N内的素数。 (C++代码)浏览:693 |
1013题解浏览:560 |
C语言程序设计教程(第三版)课后习题5.8 (C语言代码)浏览:1170 |