鞠弘俊


私信TA

用户名:jhjturn

访问量:11307

签 名:

等  级
排  名 208
经  验 6244
参赛次数 0
文章发表 61
年  龄 0
在职情况 学生
学  校 湖北生物科技职业学院
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int m = sc.nextInt();
		String[] str = { "zero", "one", "two", "three", "four", "five", "six",
				"seven", "eight", "nine", "ten", "eleven", "twelve",
				"thirteen", "fourteen", "fifteen", "sixteen", "seventeen",
				"eighteen", "nineteen", "twenty" };
		if (h<=20) {
			System.out.print(str[h]+" ");
		}
		else {
			System.out.print("twenty "+str[h-20]+" ");
		}
		if (m==0) {
			System.out.print("o'clock");
		}
		else if (m<=20) {
			System.out.print(str[m]);
		}
		else if (m==30) {
			System.out.print("thirty");
		}
		else if (m==40) {
			System.out.print("forty");
		}
		else if (m==50) {
			System.out.print("fifty");
		}
		else {
			switch (m/10) {
			case 2:
				System.out.print("twenty "+str[m%10]);
				break;
			case 3:
				System.out.print("thirty "+str[m%10]);
				break;
			case 4:
				System.out.print("forty "+str[m%10]);
				break;
			case 5:
				System.out.print("fifty "+str[m%10]);
				break;
			default:
				break;
			}
		}
	}
}


 

0.0分

3 人评分

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

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区