Advertisement
juanjo12x

SRM_183_Div2_500

Aug 23rd, 2014
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.35 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 <bitset>
  9. #include <queue>
  10. #include <list>
  11. #include <vector>
  12. #include <map>
  13. #include <set>
  14. #include <iterator>
  15. #include <sstream>
  16. #include <stdlib.h>
  17. #include <cmath>
  18. #define FOR(i,A) for(typeof (A).begin() i = (A).begin() ; i != (A).end() ; i++)
  19. #define debug( x ) cout << #x << " = " << x << endl
  20. #define clr(v,x) memset( v, x , sizeof v )
  21. #define all(x) (x).begin() , (x).end()
  22. #define rall(x) (x).rbegin() , (x).rend()
  23. #define TAM 110
  24.  
  25. using namespace std;
  26.  
  27. typedef pair<int,int> ii ;
  28. typedef long long ll ;
  29. typedef long double ld ;
  30. typedef pair<int,ii> pii ;
  31. typedef struct card{
  32.   char suit;
  33.   int rank;
  34. }cards;
  35.  
  36. bool cmp(const cards &a,const cards &b){
  37.    if(a.suit==b.suit){
  38.        return(a.rank<b.rank);
  39.    }else{
  40.     return(a.suit<b.suit);
  41.    }
  42. }
  43. char transforma(int c){
  44.     if(c==1)return '1';
  45.     else if(c==2) return '2';
  46.     else if(c==3) return '3';
  47.     else if(c==4) return '4';
  48.     else if(c==5) return '5';
  49.     else if(c==6) return '6';
  50.     else if(c==7) return '7';
  51.     else if(c==8) return '8';
  52.     else if(c==9) return '9';
  53.     else if(c==10) return 'T';
  54.     else if(c==11) return 'J';
  55.     else if(c==12) return 'Q';
  56.     else if(c==13) return 'K';
  57.     else return 'A';
  58. }
  59. int main() {
  60.     int t;string cad;vector<cards> v;
  61.    
  62.     scanf("%d",&t);getchar();
  63.     while(t--){
  64.         getline(cin,cad);cards aux;
  65.                  
  66.         for(int i=0;i<cad.size()-1;i=i+2){
  67.                    
  68.             aux.suit=cad[i];
  69.                         if(isdigit(cad[i+1])) aux.rank=(cad[i+1])-'0';
  70.                         else if(cad[i+1]=='A')aux.rank=14;
  71.                         else if(cad[i+1]=='J') aux.rank=11;
  72.                         else if(cad[i+1]=='Q') aux.rank=12;
  73.                         else if(cad[i+1]=='K') aux.rank=13;
  74.                         else if(cad[i+1]=='T') aux.rank=10;
  75.             v.push_back(aux);
  76.         }
  77.                
  78.                 /*for(int i=0;i<v.size();i++){
  79.                     cout<<v[i].suit<<v[i].rank<<endl;
  80.                 }*/
  81.          
  82.         sort(v.begin(),v.end(),cmp);
  83.                  
  84.                 string rpta="";
  85.         for(int i=0;i<v.size();i++){
  86.             rpta+=v[i].suit;
  87.                         rpta+=transforma(v[i].rank);
  88.         }
  89.         cout<<rpta<<endl;v.clear();
  90.     }
  91.     return 0;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement