参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); //输入时间的时和分 int h = scanner.nextInt(); int m = scanner.nextInt(); //新建数组存储数据 String[] arr= {"zero","one","two","three","four","five", "six","seven","eight","nine","ten", "eleven","twelve","thirteen","fourteen","fifteen", "sixteen","seventeen","eighteen","nineteen","twenty", "thirty","forty","fifty"}; //先读取h if (h <= 20) { System.out.print(arr[h] + " "); }else { //如果大于20小于60的 //先读取整十的数,然后再加上个位数 System.out.print(arr[h - h % 10] + " " + arr[h % 10] + " "); } //再读取m if (m == 0) { System.out.println("o'clock"); }else { if (m <= 20) { System.out.println(arr[m] + " "); }else { //大于20小于60的 //30 40 50 在数组中的索引是21 22 23 int x = m / 10 - 2;//获取30,40 50中的3 4 5 - 2 = 1 2 3 System.out.println(arr[20 + x] + " " + arr[m % 10]); } } } }
0.0分
1 人评分
C语言程序设计教程(第三版)课后习题8.1 (C语言代码)浏览:442 |
C语言程序设计教程(第三版)课后习题1.5 (C++代码)浏览:772 |
WU-输出九九乘法表 (C++代码)浏览:1838 |
大家好,我是验题君浏览:595 |
GC的苦恼 (C语言代码)浏览:663 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:635 |
WU-C语言程序设计教程(第三版)课后习题12.3 (C++代码)浏览:918 |
字符删除 (C语言代码)浏览:759 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:487 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:437 |