makrusak

cards

Dec 10th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <iostream>
  4. #include <algorithm>
  5. #include <vector>
  6. #include <string>
  7. #include <string.h>
  8. #include <queue>
  9. #include <stack>
  10. #include <deque>
  11. #include <map>
  12. #include <set>
  13. #include <cmath>
  14. #include <sstream>
  15. #include <ctime>
  16.  
  17. #define pb push_back
  18. #define mp make_pair
  19. #define PI 3.1415926535897932384626433832795
  20. #define ALL(x) x.begin(), x.end()
  21. #define F first
  22. #define S second
  23. #define m0(x) memset(x,0,sizeof(x))
  24. #define m1(x) memset(x,-1,sizeof(x))
  25. #define pw(x) (1ull<<(x))
  26.  
  27. using namespace std;
  28. typedef long long ll;
  29. typedef unsigned long long ull;
  30. typedef long double ld;
  31. typedef pair<int,int> pii;
  32. const int INF = 2147483647;
  33. const ll LLINF = 9223372036854775807LL;
  34.  
  35. const char pr[] = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A', 'c', 's', 'h', 'd' };
  36.  
  37. inline int prior(char c) {
  38.   int ans = 0;
  39.   while (pr[ans]!=c) ans++;
  40.   return ans;
  41. }
  42.  
  43. bool comp(const Card &a, const Card &b) {
  44.   if (a.suit == b.suit) return prior(a.rank)<prior(b.rank);
  45.   else return prior(a.suit)<prior(b.suit);
  46. }
  47.  
  48. void sort_card(int n, Card card[]) {
  49.   sort(card, card+n, comp);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment