蓝色


私信TA

用户名:uq_73524036976

访问量:429

签 名:

等  级
排  名 2478
经  验 2286
参赛次数 0
文章发表 4
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章


解题思路:

注意事项:

参考代码:

import java.io.BufferedInputStream;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(new BufferedInputStream(System.in));
        int h = scanner.nextInt(),m = scanner.nextInt();
        String sn[] = {"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven"
                        ,"twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"
                        ,"twenty"};
        String snn[] = {"thirty","forty","fifty"};//这个数组是把20,30,40,50放在里面,
        if(m != 0){
            //先判断h
            if(h > 20){
                System.out.print("twenty"+" "+sn[h%10]+" ");
            }
            else {
                System.out.print(sn[h]+" ");
            }
            //再判断m
            //用m%10判断个位是否为0
            if(m%10 == 0){
                if(m > 20){
                    System.out.print(snn[m/10-3]);
                }
                else {
                    System.out.print(sn[m]);
                }
            }
            else{
                if(m > 20){
                    System.out.print(snn[m/10-2]+" "+sn[m%10]);
                }
                else {
                    System.out.print(sn[m]);
                }
            }
        }
        else {
            if(h > 20){
                System.out.print("twenty"+" "+sn[h%10]+"o'clock");
            }
            else {
                System.out.print(sn[h]+" "+"o'clock");
            }
        }
    }
}


 

0.0分

0 人评分

  评论区

  • «
  • »