Poj 2328 guessing game

Source: Internet
Author: User

// The question is relatively simple .. That is, one person said one number, and the other said too high or too low .. Then you can determine whether this is a lie .. The idea is
// If it is too high, judge whether the value of L is smaller than n. If it is small, it proves that the lie is true, and the evidence is also true .. If not, update L and R. ,
# Include <iostream>
# Include <string. h>
# Include <stdio. h>
Using namespace STD;
Int main ()
{
Int N;
Char string [10];
Int L = 0, r = 11;
Int flag = 0;
While (scanf ("% d", & N )! = EOF)
{
If (n = 0)
Break;
Getchar ();
Gets (string );
Int S = strlen (string );
If (string [s-1] = 'n ')
{
If (n <= L | n> = r)
Flag = 1;
If (FLAG)
Printf ("Stan is dishonest \ n ");
Else
Printf ("Stan may be honest \ n ");
Flag = 0;
L = 0;
R = 11;
}
If (string [s-1] = 'H ')
{
If (n <= L)
Flag = 1;
Else
{
If (n <R)
R = N;
}
}
If (string [s-1] = 'W ')
{
If (n> = r)
Flag = 1;
Else
{
If (n> L)
L = N;
}
}
}
Return 0;
}

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.