Kevin234


私信TA

用户名:Kevin234

访问量:18933

签 名:

手可摘星辰

等  级
排  名 868
经  验 3456
参赛次数 0
文章发表 40
年  龄 0
在职情况 学生
学  校 南京信息工程大学
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

import java.util.HashMap;
import java.util.Scanner;

public class T1468 {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		HashMap<Integer,String> map = new HashMap<>();
		String digit[] = {"zero","one","two","three","four","five","six","seven",
						  "eight","nine","ten","eleven","twelve","thirteen","fourteen",
						  "fifteen","sixteen","seventeen","eighteen","nineteen",
						  "twenty","twenty one","twenty two","twenty three"};
		for(int i = 0;i<=23;i++)
			map.put(i, digit[i]);
		map.put(30, "thirty");
		map.put(40, "forty");
		map.put(50, "fifty");
		while(in.hasNext()) {
			int h = in.nextInt(),m = in.nextInt();
			String ans = "";
			if(m == 0) {
				ans = map.get(h)+" o'clock";
			}
			else if(0<m&&m<=20 || m%10==0){
				ans = map.get(h) +" "+ map.get(m);
			}
			else {
				ans = map.get(h)+" "+map.get(m/10*10)+" "+map.get(m%10);
			}
			System.out.println(ans);
		}
		in.close();
	}
}


 

0.0分

2 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区