zoukankan      html  css  js  c++  java
  • 数字转成字母型


    // TODO Auto-generated method stub





    /*
    * 输入一个数字转换为一个汉字读法字符串
    */
    while(true){
    System.out.println("请输入一个数字:");
    Scanner scan = new Scanner(System.in);
    int b = scan.nextInt();
    char[] arr = {'零','一','二','三','四','五','六','七','八','九'};
    char[] arr1 = {'十','百','千','万','十','百','千','亿','十','百','千'};
    char[] arr2 = new char[24];
    int temp = 10;
    int index = 0;
    for(int j = 0;j < 12;j++){
    arr2[index++] = arr[b%temp];    //取余
    arr2[index++] = arr1[j];
    b /= temp;     //b = b/temp; num += 10;num = num+10   
    if(b == 0){
    break;
    }

    }
    for(int j = index-2;j >= 0;j-- ){       //由于是倒着排列,而我们是顺着读取,所有反排序一次
    System.out.print(arr2[j]);

    }

    }

  • 相关阅读:
    python解析网页
    node.js 爬虫
    c++ split实现
    foldl foldr
    爬虫http header gzip
    命令[10]
    命令[08]
    命令[15]
    命令[13]
    命令[11]
  • 原文地址:https://www.cnblogs.com/xiaoshuaidiboke/p/7151958.html
Copyright © 2011-2022 走看看