C Language similar to ""

Source: Internet
Author: User

I think of a C language question answered by Baidu last semester, as shown below:

------------------------------------

 
# Include "stdio. H "Main () {int A = 1, B = 2, c = 3, T; while (A <B <c) {T = A; A = B; B = T; c --;} printf ("% d, % d, % d", a, B, c );}

 
What is the answer? Why? The answer is not 2 1 2

-------------------------------------

This is my answer.

 
The answer should be 121. The problem lies in the loop condition of while (). In fact, this loop is executed twice, in parentheses, the actual judgment process of a> B> C is to first judge whether A> B is true. If it is true, 1 is returned, that is, (A> B) is changed to 1, then compare it with C. If it is false, 0 is returned. That is to say, after comparing a and B, (A> B) is changed to a specific value (1 or 0) and C. According to this principle,ProgramIt repeats twice. If the brackets contain while (A <B & B <C), the program runs once and the answer is 212.

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.