Read integer,

Source: Internet
Author: User

Read integer,

Subject content:

Your program needs to read an integer in the range of [-100000,100000]. Then, output each digit of the integer in Chinese pinyin.

If 1234 is input, the output is:

Yi er san si

Note that there is a space between the pinyin characters, but there is no space behind the last word. When a negative number is encountered, add "fu" at the beginning of the output, for example,-2341 output:

Fu er san si yi

 

Input Format:

An integer in the range of [-100000,100000].

 

# Include <stdio. h>

Int main (){
Int a, digit = 100000;
Scanf ("% d", & );

If (a <0 ){
Printf ("fu ");
A =-;
}

While (digit> 1)
{
If (a/digit! = 0)
{
Break;
}
Digit/= 10;
}

For (; digit> 0; digit/= 10 ){
Switch (a/digit)
{
Case 1:
Printf ("yi ");
Break;
Case 2:
Printf ("er ");
Break;
Case 3:
Printf ("san ");
Break;
Case 4:
Printf ("si ");
Break;
Case 5:
Printf ("wu ");
Break;
Case 6:
Printf ("liu ");
Break;
Case 7:
Printf ("qi ");
Break;
Case 8:
Printf ("ba ");
Break;
Case 9:
Printf ("jiu ");
Break;
Case 0:
Printf ("ling ");
Break;
}
A-= (a/digit) * digit;
If (digit! = 1 ){
Putchar ('');
}
}
Return 0;
}

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.