The basic algorithm of C language 12-who is the champion

Source: Internet
Author: User

/*
==================================================================
Title: B-Butyl Four people guess A,b,c,d,e,f6 individual who is the champion, a said not A is B, B said
Definitely not C, and C said it could not be a and B, Ding said is a or B, the game results said four people only one
That's right!
==================================================================
*/
#include <stdio.h>
Main ()
{
int jia,yi,bin,ding;
char i;
for (i= ' A '; i<= ' F '; i++)
{
Jia= (i== ' A ' | | i== ' B ');//actually are logical judgments, really 1, false for 0, thereby achieving the additive, finally add up is a few people say right!
yi= (i!= ' C ');
bin= (i!= ' A ' &&i!= ' B ');
ding= (i== ' A ' | | i== ' B ');
if (jia+yi+bin+ding==1)
printf ("The Championship is:%c\n", i);
}
}
/*
==================================================================
Comments: The four people's statement in a logical language, really 1, false 0, four people added to a few
That's right! You can modify the IF statement to have a value of 2 or 3 to try (2 or 3 people say yes).
==================================================================
*/

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The basic algorithm of C language 12-who is the champion

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.