Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <string>
- #include <cctype>
- #include <stack>
- #include <queue>
- #include <list>
- #include <vector>
- #include <map>
- #include <set>
- #include <sstream>
- #include <stdlib.h>
- #include <cmath>
- #define LL unsigned long long
- using namespace std;
- bool isfull(int full[],int n){
- for(int i=0;i<n;i++){
- if(full[i]==0) return false;
- }
- return true;
- }
- /*funcion que verifica que existe dicho elemento ya antes*/
- bool existe(char guess[],int k){
- for (int i=0;i<k;i++){
- if(guess[i]==guess[k]) return true;
- }
- return false;
- }
- int main() {
- int round,n,n1,hang;char key[1000];char guess[1000];bool found;
- while(scanf("%d",&round)){
- if(round==-1) break;
- cin>>key;
- cin>>guess;
- hang=0;
- n=strlen(key);n1=strlen(guess);
- int full[n];
- /*inicializo el arreglo de booleanos*/
- memset(full, 0, sizeof(int) * n);
- for (int i=0;i<n1;i++){
- found=false;/*inicializo found*/
- for (int j=0;j<n;j++){
- if(guess[i]==key[j]){
- full[j]=1;/*para cada posicion encontrada*/
- found=true;
- }
- }
- if(!found && (!(existe(guess,i)))) hang++;/*si no encontro para ninguna posicion*/
- if(hang==7) break;
- if(isfull(full,n)) break;
- }
- printf("Round %d\n",round);
- if (isfull(full,n)) printf("You win.\n");
- else if(hang==7) printf("You lose.\n");
- else if(hang<7) printf("You chickened out.\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement