hdu 2629

18 篇文章 1 订阅

这题不知道怎么回事,刚开始写出来的代码运行结果正确,但是通过不了,现在的代码把switch加入到单独的方法里也通过不了,参考了其他大佬的代码,能通过的只写出来了这个。

import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
            Scanner input = new Scanner(System.in);
            int n = input.nextInt();
            while (n-->0){
                String ID = input.next();
                int  distinct_ID = Integer.parseInt(ID.substring(0,2));
                String distinct = new String();
                switch (distinct_ID) {
                    case 33:
                        distinct = "Zhejiang";
                        break;
                    case 11:
                        distinct= "Beijing";
                        break;
                    case 71:
                        distinct= "Taiwan";
                        break;
                    case 81:
                        distinct= "Hong Kong";
                        break;
                    case 82:
                        distinct= "Macao";
                        break;
                    case 54:
                        distinct= "Tibet";
                        break;
                    case 21:
                        distinct= "Liaoning";
                        break;
                    case 31:
                        distinct= "Shanghai";
                        break;
                }
                System.out.println("He/She is from " + distinct + ",and his/her birthday is on " + ID.substring(10, 12) + "," + ID.substring(12, 14) + "," + ID.substring(6, 10) + " based on the table.");
            }
        }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值