Introduction to Programming--c Language 4th week programming exercises 2 read integers (5 points)

Source: Internet
Author: User
Tags pow

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:

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:

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

main.c//c yuyan////Created by Anzhongyin on 2016/11/29.//Copyright? 2016 Anzhongyin. All rights reserved.//#include <stdio.h> #include <math.h>int main (int argc, const char * argv[]) {//Inser    T code here ... int i;    scanf ("%d", &i);        int n=0;        if (i<0) {printf ("fu");    I=i*-1;    } int m=i;        while (m>0) {M=M/10;    n++;  } if (i==0) {printf ("ling\n");           } for (int j=n-1;j>=0;j--) {int b=i/(POW (10,j));                        i=i% (int) pow (10,j);                Switch (b) {case 0:printf ("Ling");            Break                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        } if (j!=0) {printf ("");        } else {printf ("\ n"); }    }   }

  

Use case test Results

Run time

Memory consumption

Tips

Score

Use Case 1 by

1ms

256kb

1

Use Case 2 by

1ms

128kb

1

Use Case 3 by

1ms

256kb

1

Use Case 4 by

1ms

256kb

1

Use Case 5 by

1ms

128kb

1

Submit an Answer

Score/Score:5.00/5.00 min

Introduction to Programming--c Language 4th week programming exercises 2 read integers (5 points)

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.