Advertisement
juanjo12x

UVA_11225_Tarot_Scores

Jul 23rd, 2014
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <cstring>
  5. #include <string>
  6. #include <cctype>
  7. #include <stack>
  8. #include <queue>
  9. #include <list>
  10. #include <vector>
  11. #include <map>
  12. #include <set>
  13. #define N 1000000
  14. #define LL unsigned long long
  15. using namespace std;
  16.  
  17. int new_min(int oudlers){
  18.  switch(oudlers){
  19.     case 1: return  51;
  20.     case 2: return 41;
  21.     default: return 36;
  22.  }
  23.  
  24. }
  25.  
  26. int main() {
  27.     int t,ncards,oudlers,min;double points;
  28.         bool oudler,flag;
  29.     scanf("%d",&t);int cont =1;
  30.     char cad[40];char *oc,*oc1;
  31.     flag=false;
  32.     while(t--){
  33.         if(flag){
  34.             flag=false;
  35.             printf("\n");
  36.         }
  37.         scanf("%d",&ncards);
  38.         getchar();
  39.         points=0;
  40.         oudlers=0;
  41.         min=56;
  42.         for (int i=0;i<ncards;i++){
  43.                        
  44.                         oudler=false;
  45.                         gets(cad);
  46.             /*verifico si es un fool*/
  47.             oc = strstr(cad,"fool");
  48.             if (oc==NULL) {
  49.                 oc=strstr(cad,"twenty-one");
  50.                 if(oc==NULL){
  51.                     oc=strstr(cad,"one");
  52.                     oc1=strstr(cad,"trumps");
  53.                     if(oc && oc1){
  54.                     points+=4.5;
  55.                     oudlers++;
  56.                     min=new_min(oudlers);
  57.                                         oudler=true;
  58.                     }
  59.                
  60.                 }else{
  61.                                     points+=4.5;
  62.                         oudlers++;
  63.                     min=new_min(oudlers);
  64.                                     oudler=true;
  65.                                 }
  66.            
  67.             }else{
  68.                 points+=4.5;
  69.                 oudlers++;
  70.                 min=new_min(oudlers);
  71.                                 oudler=true;
  72.             }
  73.             oc = strstr(cad,"king");
  74.             if (oc){
  75.                 points+=4.5;
  76.             }else{
  77.                oc = strstr(cad,"queen");
  78.                if(oc){
  79.                 points+=3.5;
  80.                }else{
  81.                  oc = strstr(cad,"knight");
  82.                  if(oc){
  83.                     points+=2.5;
  84.                  }else{
  85.                     oc=strstr(cad,"jack");
  86.                     if(oc){
  87.                         points+=1.5;
  88.                     }else{
  89.                                     if(!oudler)
  90.                         points+=0.5;
  91.                     }
  92.                  }
  93.                }
  94.             }
  95.                    
  96.                    
  97.        
  98.         }
  99.                 printf("Hand #%d\n",cont);
  100.                 if(points<min){
  101.                     cout << "Game lost by " << min - points << " point(s).\n";
  102.                    flag=true;
  103.                 }else{
  104.                     cout << "Game won by " << points -min << " point(s).\n";
  105.                   flag=true;
  106.                 }
  107.                 cont++;
  108.     }
  109.     return 0;
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement