Bank currency Unit Arabic numerals conversion Chinese capital Eclipse C and Java implementation MOOC

Source: Internet
Author: User

Let's start with a simple one: Mooc see above

Enter an integer that prints the phonetic alphabet for each number. When the integer is negative, the word "fu" is first output. 10 numbers correspond to the following pinyin:

0:ling

1:yi

2:er

3:san

4:si

5:wu

6:liu

7:qi

8:ba

9:jiu


Input format:


The input gives an integer in a row, such as: 1234 .


Tip: integers include negative numbers, 0, and positive numbers.


Output format:


In a row output this integer corresponding to the pinyin, each number of pinyin separated by a space, there is no last space at the end of the line. such as Yi er san si.

Input Sample:-600 Output example: Fu Liu Ling Ling

To this is not to see what taste 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0028.gif "alt=" J_0028.gif "/> it's easy to see.

I have at least n ways to achieve ...

650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0006.gif "alt=" j_0006.gif "/> Array index method (some examples used later), branch selection method, Recursive stitching, and the ability to use enumerations ... What else is there? 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0022.gif "alt=" J_0022.gif "/> don't Tell you

Here's the code for this example:

#include <stdio.h>int main ()  {void int_to_string (int n)  {switch  (n)  { case -1:printf ("%s",  "Fu"), break;case 0:printf ("%s",  "Ling"); break;case 1:printf ("%s" ,  "Yi"); break;case 2:printf ("%s",  "ER") break;case 3:printf ("%s",  "San"); break;case  4:printf ("%s",  "Si"); break;case 5:printf ("%s",  "WU"); break;case 6:printf ("%s",  "Liu"); break;case 7:printf ("%s",  "Qi"), break;case 8:printf ("%s",  "ba"); Break;case 9: printf ("%s",  "JIU"); break;default:break;}} Void string_output (Int num)  {if  (num / 10)  {string_output (num /  ;if  (num / 10)  != 0)  {printf (" ");} Int_to_string (num % 10);}  else {int_to_string (num);}} Void int_to_reverse (Int num)  {if  (num < 0)  {num = -num;int_to_ String ( -1);p rintf (" "); string_output(num);}  else if  (num == 0)  {int_to_string (0);}  else {string_output (num);}} INT&NBSP;NUM;SCANF ("%d",  &num); Int_to_reverse (num); return 0;}


╮(╯▽╰)╭, this is a stupid way to do it.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/47/BC/wKioL1P_DHaS8YH8AAPenR7OGFM326.jpg "title=" Digital conversion. png "alt=" wkiol1p_dhas8yh8aapenr7ogfm326.jpg "/>

Oh, forget it, leave an address for the audience, you know, you know, good stuff.


Here's a complicated one, and it's going to be the next one.

Amount conversion, the amount of Arabic numerals converted into Chinese traditional form

such as: 105600123 = zero thousand Wu Bai Lu pick up 0 thousand hundred three round the whole

650) this.width=650, "src=" Http://img.baidu.com/hi/jx2/j_0016.gif "alt=" J_0016.gif "/>" 650 ; "Src=" Http://s3.51cto.com/wyfs02/M01/47/BA/wKiom1P_DJKwsQMhAAHoV_ZwYzQ689.jpg "title=" Start Eclipse appears svn.png "alt=" Wkiom1p_djkwsqmhaahov_zwyzq689.jpg "/>


The computer does not ╮(╯▽╰)╭, eclipse GCC + java double open fast hung 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0049.gif "alt=" j_0049. GIF "/>

/** * project interview * package   com.java.interview.algorithm.other  * filename  money_convert.java * description todo * companyitser  ltd. * copyright 2014  * all rights reserved, designed  By ITSer *  *  @author  Dev-Wangxin *  @version  v1.0 *  createdate 2014 August 28   PM 7:04:04 * * modification  history *  Date          Author         Version        Description * ------------- ---------------------------------------------------------------------- * 2014 August 28         Wangxin          1.0              1.0 * why & what is modified */ package com.java.interview.algorithm.other;/** * classname money_convert<br> *  Description  currency conversion <BR> *  *  @author  Dev-Wangxin *  @date  2014 August 28   PM 7:04:04 * */public class money_convert {public static  void main (String[] args)  {string money = convert_to_chinese (105600123); SYSTEM.OUT.PRINTLN (Money), int i = convert_to_number (money); System.out.println (i);} private static final char[] data = new char[] {  ' 0 ',  ' one ',   ' II ',  ',  ', ' Wu ',  ' lu ',  ' qi ',  ' ba ',  ' JIU '  };p rivate static  final char[] units = new char[] {  ' round ',  ' pick ',  ' bai ',  ' thousand ',  ' Million ', ' Pick ',  ' bai ',  ' thousand ',  ' billion '  };/** *  * <p> * methodname: convert_to_number<br> *  description:  convert uppercase Chinese currency to Arabic-style <br> * create_by: wangxin<br> * create _date: 2014 August 28   PM 7:06:50<br> * modification with annotation or  not<BR> * </p> *  *  @param  money *  @return  int */public static int convert_to_number (String money)  {char[] m  = money.tochararray ();int length = m.length; Stringbuffer sb = new stringbuffer ();for  (int i = length - 3 ;  i >= 0; i -= 2)  {switch  (m[i])  {case  ' 0 ': Sb.insert (0,  0);break;case  ' one ': Sb.insert (0, 1);break;case  ' II ': Sb.insert (0, 2);break;case  ' three ' : Sb.insert (0, 3);break;case  ' Restaurant ': Sb.insert (0, 4);case  ' Wu ': Sb.insert (0, 5);break;case  ' lu ': Sb.insert (0, 6);break;case  ' qi ': Sb.insert (0,  7);break;case  ' ba ': Sb.insert (0, 8);break;case  ' JIU ': Sb.insert (0, 9); break;}} Return integer.parseint (Sb.tostring ());} /** *  * <p> * methodname: convert_to_chinese<br> *  description:  convert Arabic numeral currency to uppercase Chinese <br> * create_by: wangxin<br> * create_ date: 2014 August 28   PM 7:06:43<br> * modification with annotation or  not<BR> * </p> *  *  @param  money *  @return  string */public static string convert_to_chinese (Int money)  {StringBuffer  sb = new stringbuffer ("whole");int unit = 0;while  (money != 0)  {sb.insert (0, units[unit++]); Int number = money % 10;sb.insert (0, data[number]); money /= 10;} Return sb.tostring ();}}

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/47/BC/wKioL1P_D2zzMmthAAS0iSCULxE542.jpg "title=" Currency conversion. png "alt=" wkiol1p_d2zzmmthaas0isculxe542.jpg "/>

Oh, have you seen so many comments in my code? That is not handwritten, automatically generated (⊙o⊙) Oh 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0044.gif "alt=" J_0044.gif "/> will not search ha, My template will be put on the address.

My Eclipse Code comment Template

This article is from the "Long Road" blog, please be sure to keep this source http://wangxin88.blog.51cto.com/3228434/1546266

Bank currency Unit Arabic numerals conversion Chinese capital Eclipse C and Java implementation MOOC

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.