9-9-02. Write this number and write it in 9-9-02.

Source: Internet
Author: User

9-9-02. Write this number and write it in 9-9-02.
1002. Write this number (20) Time Limit 400 ms memory limit 65536 kB code length limit 8000 B discriminant program Standard author CHEN, Yue

Read a natural number n, calculate the sum of all its numbers, and write each digit in Chinese pinyin.

Input Format:Each test input contains one test case, that is, the value of natural number n. N must be less than 10100.

Output Format:Output each digit of n in a row. There is a space between the pinyin numbers, but there is no space after the last pinyin number in a row.

Input example:
1234567890987654321123456789
Output example:
yi san wu

# Include <stdio. h>

Int main ()
{
Char str [50];
Int arr [100], j = 0;
Int I, sum = 0, temp;
Gets (str );
For (I = 0; I <strlen (str); I ++)
{
Sum = sum + (str [I]-'0 ');
}
While (sum! = 0)
{
Temp = sum % 10;
Sum = sum/10;
Arr [j] = temp;
J ++;
}
For (I = J-1; I> 0; I --)
{
Switch (arr [I])
{
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;
}
}
Switch (arr [0])
{
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;
}
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.