报时助手
程序员文章站
2022-03-14 09:46:41
...
import java.util.Scanner;
public class Main{
private static String [] time1={"zero","one","two","three","four","five","six","seven","eight","nine","ten",
"eleven","twelve","thirteen","fourteen","fifteen","sixteen","eighteen","nineteen"};
private static String [] time2={"twenty","thirty","forty","fifty"};
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int h=scan.nextInt();
int m=scan.nextInt();
if(h<20){
System.out.print(time1[h]);
}else if(h==20){
System.out.print(time2[0]);
}else if(h>20&&h<24){
System.out.print(time2[0]+" "+time1[h-20]);
}
if(m==0){
System.out.print(" "+"o'clock");
}else{
if(m<20){
System.out.print(" "+time1[m]);
}else if(m>=20&&m<60){
int a=m/10;
int b=m%10;
System.out.print(" "+time2[a-2]+" "+time1[b]);
}
}
}
}
上一篇: 不太能够习惯PDF的操作Word文档怎么打印PDF文件
下一篇: PHP 高手之路(一)