Introduction to the design of NetEase cloud Classroom-C language _ Fourth week: Cyclic control _2 integer

Source: Internet
Author: User

2 read integers (5 points)

Topic content:

Your program is going to read an integer in the range [ -100000,100000]. Then, use Hanyu Pinyin to output each bit of this integer.

If you enter 1234, the output:

    1. Yi er san si

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

    1. Fu er san si yi

Input format:

An integer that ranges from [ -100000,100000].

Output format:

The pinyin that represents each digit of the integer, with a space separating the pinyin for each digit, and no space at the end.

Input Sample:

-30

Sample output:

Fu San Ling

time limit: 500ms memory limit: 32000kb
1#include <stdio.h>2#include <math.h>3 Main ()4 {5     intx;6scanf"%d", &x);7     intCNT =0;8     intT;9     inty;Ten  One     if(X <0) A     { -t =-x; -     } the     Elset =x; -      -      Do -     { +t = t/Ten; -cnt++; +} while(T >0); A      aty = Pow (Ten, (CNT-1)); -      -     if(X <0) -     { -printf"Fu"); -t =-x; in     } -     Elset =x; to      +      Do -     { the         Switch(t/y) *         { $          Case 0:p rintf ("Ling"); Break;Panax Notoginseng          Case 1:p rintf ("Yi"); Break; -          Case 2:p rintf ("er"); Break; the          Case 3:p rintf ("San"); Break; +          Case 4:p rintf ("si"); Break; A          Case 5:p rintf ("Wu"); Break; the          Case 6:p rintf ("Liu"); Break; +          Case 7:p rintf ("Qi"); Break; -          Case 8:p rintf ("BA"); Break; $          Case 9:p rintf ("JIU"); Break; $         } -         if(Y >9) -         { theprintf" "); -         }Wuyit = t%y; they = y/Ten; -} while(Y >0); Wu}

Introduction to the design of NetEase cloud Classroom-C language _ Fourth week: Cyclic control _2 integer

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.