zoukankan      html  css  js  c++  java
  • 将阿拉伯数字转换为其对应的中文数字

    郑重声明,尽管这样子不文明,但还是先对这破电脑发泄发泄吧,不对人发泄就没有伤害!

    妈蛋,这年头使用电脑太多,离开的电脑就是这么的个东西都写不出来了,真是丢人丢大了!

    今天去面试,从市政府做的是8路公交,应聘的是517号金色堤岸写字楼11层,可谓“一生一世要发了”啊!但估计挂了!不是老天不长眼,而是才知道自己有多菜,做项目再多有什么用?????????????????????????????????????????????回来自己在电脑上一试,妈蛋,好简单,手写就是写不出来!讨厌死了!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    package numbertochinese;

    import java.util.Scanner;

    /**
     * @author Administrator
     * 将阿拉伯数字转换为其对应的中文数字
     */
    public class NumberTochinese {

     private static String theNumber = null;
     private String theChinese = null;
     
     private String action(String theNumber2){
      String tadi = String.valueOf(theNumber2);
      for(int i=0; i<tadi.length(); i++){
       char mychar = tadi.charAt(i);
       String st = null;
       switch (mychar) {
       case '1':
        st = "一";
        break;
       case '2':
        st = "二";
        break;
       case '3':
        st = "三";
       case '4':
        st = "四";
        break;
       case '5':
        st = "五";
        break;
       case '6':
        st = "六";
        break;
       case '7':
        st = "七";
        break;
       case '8':
        st = "八";
        break;
       case '9':
        st = "九";
        break;
       case '0':
        st = "零";
        break;
       default:
        break;
       }
       if(null == theChinese){
        theChinese = st;
       }else{
        theChinese += st;
       }
      }
      if(null == theChinese){
       return theChinese = "您输入的不是数字!";
      }else if(theChinese.length() != theNumber.length()){
       return theChinese = "您输入的数字不符合规则!";
      }else{
       return theChinese;
      }
     }
     
     public static void main(String[] args) {
      NumberTochinese tochinese = new NumberTochinese();
      System.out.println("请输入一个或多个阿拉伯数字:");
      try {
       Scanner scanner = new Scanner(System.in);
       theNumber = scanner.next();
       tochinese.theChinese = tochinese.action(theNumber);
      } catch (Exception e) {
       e.printStackTrace();
      }
      System.out.println(tochinese.theChinese);
     }
    }

  • 相关阅读:
    CCF CSP 201509-1 数列分段
    CCF CSP 201503-1 图像旋转 (降维)
    CCF CSP 201412-1 门禁系统
    CCF CSP 201409-1 相邻数对
    CCF CSP 201403-1 相反数
    CCF CSP 201312-1 出现次数最多的数
    Win10环境下 HTTP 错误 500.19
    牛客网 整数拆分 (动态规划)
    牛客网 放苹果
    LeetCode9 回文数
  • 原文地址:https://www.cnblogs.com/lanjianqing/p/4119637.html
Copyright © 2011-2022 走看看