Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <string>
- #include <cctype>
- #include <stack>
- #include <bitset>
- #include <queue>
- #include <list>
- #include <vector>
- #include <map>
- #include <set>
- #include <iterator>
- #include <sstream>
- #include <stdlib.h>
- #include <cmath>
- #define FOR(i,A) for(typeof (A).begin() i = (A).begin() ; i != (A).end() ; i++)
- #define debug( x ) cout << #x << " = " << x << endl
- #define clr(v,x) memset( v, x , sizeof v )
- #define all(x) (x).begin() , (x).end()
- #define rall(x) (x).rbegin() , (x).rend()
- #define TAM 110
- using namespace std;
- typedef pair<int,int> ii ;
- typedef long long ll ;
- typedef long double ld ;
- typedef pair<int,ii> pii ;
- typedef struct card{
- char suit;
- int rank;
- }cards;
- bool cmp(const cards &a,const cards &b){
- if(a.suit==b.suit){
- return(a.rank<b.rank);
- }else{
- return(a.suit<b.suit);
- }
- }
- char transforma(int c){
- if(c==1)return '1';
- else if(c==2) return '2';
- else if(c==3) return '3';
- else if(c==4) return '4';
- else if(c==5) return '5';
- else if(c==6) return '6';
- else if(c==7) return '7';
- else if(c==8) return '8';
- else if(c==9) return '9';
- else if(c==10) return 'T';
- else if(c==11) return 'J';
- else if(c==12) return 'Q';
- else if(c==13) return 'K';
- else return 'A';
- }
- int main() {
- int t;string cad;vector<cards> v;
- scanf("%d",&t);getchar();
- while(t--){
- getline(cin,cad);cards aux;
- for(int i=0;i<cad.size()-1;i=i+2){
- aux.suit=cad[i];
- if(isdigit(cad[i+1])) aux.rank=(cad[i+1])-'0';
- else if(cad[i+1]=='A')aux.rank=14;
- else if(cad[i+1]=='J') aux.rank=11;
- else if(cad[i+1]=='Q') aux.rank=12;
- else if(cad[i+1]=='K') aux.rank=13;
- else if(cad[i+1]=='T') aux.rank=10;
- v.push_back(aux);
- }
- /*for(int i=0;i<v.size();i++){
- cout<<v[i].suit<<v[i].rank<<endl;
- }*/
- sort(v.begin(),v.end(),cmp);
- string rpta="";
- for(int i=0;i<v.size();i++){
- rpta+=v[i].suit;
- rpta+=transforma(v[i].rank);
- }
- cout<<rpta<<endl;v.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement