Advertisement
juanjo12x

UVA_10530_Guessing_Game

Jul 31st, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cstring>
  5. #include <string>
  6. #include <cctype>
  7. #include <vector>
  8. #include <map>
  9. #include <set>
  10. #include <math.h>
  11. #define For(a) for ( i = 0; i < a; i++ )
  12. #define Rep(a, b) for ( i = a; i <= b; i++ )
  13. #define N 1000000
  14. using namespace std;
  15.  
  16.  
  17. int main ()
  18. {
  19.     int guess;
  20.     char ans1 [10];
  21.     char ans2 [10];
  22.  
  23.     while ( scanf ("%d", &guess) && guess ) {
  24.  
  25.         int high = 11;
  26.         int low = 0;
  27.  
  28.         while ( scanf ("%s %s", ans1, ans2) && strcmp (ans1, "right") != 0 ) {
  29.             if ( strcmp (ans2, "high") == 0 ) {
  30.                 if ( guess <= high )
  31.                     high = guess - 1;
  32.             }
  33.  
  34.             else if ( strcmp (ans2, "low") == 0 ) {
  35.                 if ( guess >= low )
  36.                     low = guess + 1;
  37.             }
  38.             scanf ("%d", &guess);
  39.         }
  40.  
  41.         if ( guess < low || guess > high || low > high )
  42.             printf ("Stan is dishonest\n");
  43.         else
  44.             printf ("Stan may be honest\n");
  45.  
  46.     }
  47.  
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement