解题思路:
注意事项:
参考代码:
import java.io.*; import java.util.ArrayList; import java.util.HashMap; public class Main { static StreamTokenizer cin; static PrintWriter out; static int h; // 时 static int m; // 分 static HashMap<Integer, String> map; public static void main(String[] args) throws IOException{ cin = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); out = new PrintWriter(new OutputStreamWriter(System.out)); h = nextInt(); m = nextInt(); map = new HashMap<>(); initMap(); StringBuilder str = new StringBuilder(); for(int item : splitH()) str.append(map.get(item)).append(" "); if(m == 0) str.append("o'clock"); else{ for(int item : splitM()){ str.append(map.get(item)).append(" "); } } out.println(str.toString()); out.flush(); } static ArrayList<Integer> splitH(){ ArrayList<Integer> list = new ArrayList<>(); if(h > 20){ int s1 = h%10; // 个位 int s2 = h-s1; // 十位 list.add(s2); if(s1 != 0) list.add(s1); }else list.add(h); return list; } static ArrayList<Integer> splitM(){ ArrayList<Integer> list = new ArrayList<>(); if(m > 20){ int s1 = m%10; // 个位 int s2 = m-s1; // 十位 list.add(s2); if(s1 != 0) list.add(s1); }else list.add(m); return list; } static void initMap(){ map.put(0, "zero"); map.put(1, "one"); map.put(2, "two"); map.put(3, "three"); map.put(4, "four"); map.put(5, "five"); map.put(6, "six"); map.put(7, "seven"); map.put(8, "eight"); map.put(9, "nine"); map.put(10, "ten"); map.put(11, "eleven"); map.put(12, "twelve"); map.put(13, "thirteen"); map.put(14, "fourteen"); map.put(15, "fifteen"); map.put(16, "sixteen"); map.put(17, "seventeen"); map.put(18, "eighteen"); map.put(19, "nineteen"); map.put(20, "twenty"); map.put(30, "thirty"); map.put(40, "forty"); map.put(50, "fifty"); } static int nextInt() throws IOException{ cin.nextToken(); return (int) cin.nval; } }
0.0分
0 人评分
输出九九乘法表 (C语言代码)浏览:555 |
九宫重排 (C++代码)浏览:2160 |
买不到的数目 (C++代码)浏览:862 |
c primer plus 第十二章 12.1小节浏览:375 |
回文串 (C语言代码)浏览:2844 |
用筛法求之N内的素数。 (C语言代码)浏览:1228 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:746 |
C语言程序设计教程(第三版)课后习题1.5 (C++代码)浏览:1078 |
格式化数据输出 (C语言代码)浏览:811 |
输出九九乘法表 (C语言代码)浏览:1048 |