I missed an exam and gave it a question --

Source: Internet
Author: User

The school took an English test. There were 10 non-questions, each entitled 10 points. The answer was expressed as "yes" and 0 as "non. However, after the instructor approved the exam, he found that he missed the exam and the standard answer was lost. Only three papers marked with scores were left on his hand.

Exam 1:
① (3) (4) (6) (7)
0 0 1 0 1 0 1 0 0 0 score: 70
Exam 2:
① (3) (4) (6) (7)
0 1 1 1 0 1 1 1 1 1 score: 50
Exam 3:
① (3) (4) (6) (7)
0 1 1 1 0 0 0 1 1 score: 30

Pending exam approval:
① (3) (4) (6) (7)
0 0 1 1 1 0 0 1 1 1 score :?
Compile 1ProgramCalculate the score of the missing exam based on the three tests.
 
Let's put it bluntly. There are only 10 questions...

# Include Cstdio >  

Int BITs ( Int A) // Calculate how many bits in a is 1
{
Int C =   0 ;
For (C =   0 ; A; c ++ )
{
A=A&(-1);
}
Return C;
}

Int Main ()
{
Int I;
Int A [ 4 ] =   {0x0a4,0x1d7,0x1c5,0x0e7,} ;
Int S [ 4 ] =   {7,5,3,0} ;

For (I =   0 ; I   1024 ; I ++ ) // Try various answers
{
If ( 10   - BITs ([ 0 ] ^ I) = S [ 0 ] &&   // A [0] ^ I indicates correcting a [0] According to the answer I. The result 1 is different (that is, the answer is wrong ).
10   - BITs ([ 1 ] ^ I) = S [ 1 ] &&
10   - BITs ([ 2 ] ^ I) = S [ 2 ]) // The answer to all scores may be the correct one.
{
S [ 3 ] =   10   - BITs ([ 3 ] ^ I ); // Calculate the score of the missing batch volume
Printf ( " % D \ n " , S [ 3 ]);
}
}  
Return   0 ;
}

The result is quite clever. Although there are multiple possible correct answers, the total score for this paper is 60 --

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.