Advertisement
Plabon_dutta

UVA 489 - Hangman Judge

May 24th, 2021
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <math.h>
  3. #include<string>
  4. #define pi acos(-1.0)
  5. #define ll long long int
  6. #define sc scanf
  7. #define pf printf
  8. #define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
  9.  
  10. using namespace std;
  11.  
  12. int main() {
  13.     while(1) {
  14.         ll t;
  15.         cin >> t;
  16.         if(t==-1) break;
  17.         string s1, s2;
  18.         cin >> s1 >> s2;
  19.         int l2=s2.size();
  20.         for(int i=0; i<l2; i++) {
  21.             int f=0;
  22.             for(int j=i+1; j<l2; j++) {
  23.                 if(s2[i]==s2[j]) f=1;
  24.             }
  25.             if(f==1) s2[i]='0';
  26.         }
  27.         int l1=s1.size(), c=0, s=0;
  28.         for(int i=0; i<l2; i++) {
  29.             int g=0;
  30.             if(s2[i]!='0') {
  31.                 for(int j=0; j<l1; j++) {
  32.                     if(s2[i]==s1[j]) {
  33.                         s++;
  34.                         g=1;
  35.                     }
  36.                 }
  37.                 if(g==0) c++;
  38.                 if(c>=7) break;
  39.             }
  40.  
  41.         }
  42.         cout << "Round " << t << "\n";
  43.         if(c>=7 && s!=l1) cout << "You lose.\n";
  44.         else if(s==l1) cout << "You win.\n";
  45.         else cout << "You chickened out.\n";
  46.     }
  47.     return 0;
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement