Advertisement
juanjo12x

UVA_10646_What_Is_The_Card?

Jul 23rd, 2014
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 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 get_value(char c){
  18.        
  19.     switch(c){
  20.         case '2': return 2;
  21.         case '3': return 3;
  22.         case '4': return 4;
  23.         case '5': return 5;
  24.         case '6': return 6;
  25.         case '7': return 7;
  26.         case '8': return 8;
  27.         case '9': return 9;
  28.         default : return 10;
  29.     }
  30. }
  31.  
  32. int main() {
  33.     string arr[52];
  34.     stack <string> s;stack <string> hand;
  35.         string cad;
  36.         int t,cont,x,y;
  37.         scanf("%d",&t);
  38.         cont=1;
  39.         while(t--){
  40.             for(int i=0;i<52;i++){
  41.                 cin>>cad;
  42.                 s.push(cad);
  43.             }
  44.             /*consigo una mano*/
  45.             for(int i=0;i<25;i++){
  46.                 hand.push(s.top());
  47.                 s.pop();
  48.             }
  49.             y=0;
  50.             /*proceso de simulación*/
  51.             for(int i=0;i<3;i++){
  52.                 /*saco la carta*/
  53.                cad=s.top();
  54.                x=get_value(cad[0]);
  55.                y+=x;
  56.                s.pop();
  57.                for(int j=0;j<10-x;j++){
  58.                 s.pop();
  59.                }
  60.             }
  61.             /*apilamos la mano*/
  62.             for(int i=0;i<25;i++){
  63.                 s.push(hand.top());
  64.                 hand.pop();
  65.             }          
  66.            int j=0;
  67.            while(!s.empty()){
  68.             arr[j]=s.top();
  69.             s.pop();
  70.             j++;
  71.            }
  72.            j--;
  73.            j=j-y;
  74.            
  75.            printf("Case %d: ",cont);
  76.            cont++;
  77.            cout<<arr[j]<<endl;
  78.            
  79.         }
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement