蓝桥杯VIP试题 基础练习 报时助手

蓝桥杯VIP试题 基础练习 报时助手

 

输入格式

  输入包含两个非负整数h和m,表示时间的时和分。非零的数字前没有前导0。h小于24,m小于60。

输出格式

  输出时间时刻的英文。

样例输入

0 15

样例输出

zero fifteen

package VIP;

import java.util.Scanner;

public class 报时助手 {
     static String x[]= {"zero", "one", "two", "three","four", "five","six","seven", "eight","nine"};
     static String y[]= {"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
     static String z[]= {"twenty","thirty","forty","fifty"};
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int h=sc.nextInt();
		int m=sc.nextInt();
       Translation(h, m); 
	}
	public static void Translation(int h,int m) {
		if (h<10) {
			System.out.print(x[h%10]+" ");
		}
		if (h>=10&&h<20) {
			System.out.print(y[h%10]+" ");
		}
		if (h>=20&&h<24) {
			if (h%10==0) {
				System.out.print(z[h/10-2]+" ");
			}else
			System.out.print(z[h/10-2]+" "+x[h%10]+" ");
		}
		
		if(m!=0) {
		   if (m<10) {
			System.out.print(x[m%10]+" ");
		}
		if (m>=10&&m<20) {
			System.out.print(y[m%10]+" ");
		}
		if (m>=20&&m<60) {
			if (m%10==0) {
				System.err.print(z[m/10-2]+" ");
			}else
			System.out.print(z[m/10-2]+" "+x[m%10]+" ");
		}
		}
		else {
		System.out.print("o'clock");	
		}
		System.out.println();
	
	}
}

 

上一篇:屏幕在C#中刮擦大型机屏幕*没有*第三方实用程序


下一篇:RAC修改spfile位置