Three digits in reverse order (Exercise on the first day), exercise on the first day of Reverse Order

Source: Internet
Author: User

Three digits in reverse order (Exercise on the first day), exercise on the first day of Reverse Order

Subject content:

Each time the program reads a positive three-digit number, it then outputs a number in reverse order. Note: When the input number contains 0 at the end, the output should not contain 0 at the beginning. For example, if the input value is 700, the output value is 7.

Input Format:

Each test is a three-digit positive integer.

Output Format:

Number of output reverse orders.

Input example:

123

Output example:

321

Time Limit: Ms memory limit: KB Program reference:

# Include <stdio. h>

Int main ()
{
Int x;

// Read three digits
Scanf ("% d", & x );

// Split the three-digit, ten-digit, and hundred-digit
Int g = x % 10;
Int B = x/2/100;
Int s = x/10-b * 10;

// Calculate the descending order of three digits
Int y = g * 100 + s * 10 + B;

// Output
Printf ("% d", y );

Return 0;
}

 

Thoughts:

I learned the questions I encountered on the first day of C language. (Learning content: output, variables, and simple computing)

When I first got a question, I was overwhelmed to describe it. After careful analysis, I found that it was not difficult. I think that in C language learning, thinking is very important.

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.