Advertisement
JosepRivaille

X79304: Daus

Jul 25th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5.  
  6. void read_vector(vector<int>& v) {
  7.   for (int i = 0; i < 5; ++i) {
  8.     cin >> v[i];
  9.   }
  10. }
  11.  
  12. int operation(const vector<int>& v) {
  13.   vector<int> aux(6, 0);
  14.   int n;
  15.   for (int i = 0; i < 5; ++i) {
  16.     int j = v[i] - 1;
  17.     ++aux[j];
  18.   }  
  19.  
  20.   bool trobat = false;
  21.   bool trio_provisional = false;
  22.   bool parella_provisional = false;
  23.   for (int i = 0; i < 6 && !trobat; ++i) {
  24.     if (aux[i] >= 4) {
  25.       trobat = true;
  26.       n = 1;
  27.     }
  28.     else if (aux[i] == 3) {
  29.       if (!parella_provisional) trio_provisional = true;
  30.       else {
  31.     trobat = true;
  32.     n = 4;
  33.       }
  34.     }
  35.     else if (aux[i] == 2) {
  36.       if (parella_provisional) {
  37.     trobat = true;
  38.     n = 2;
  39.       }
  40.       else if (trio_provisional) {
  41.     trobat = true;
  42.     n = 4;
  43.       }
  44.       else parella_provisional = true;
  45.     }
  46.   }
  47.   if (!trobat && parella_provisional) n = 5;
  48.   else if (!trobat && trio_provisional) n = 3;
  49.   else if (!trobat) n = 0;
  50.  
  51.   return n;
  52. }
  53.  
  54. void result(int n) {
  55.   if (n == 0) cout << "escala" << endl;
  56.   else if (n == 1) cout << "poker" << endl;
  57.   else if (n == 2) cout << "doble-parella" << endl;
  58.   else if (n == 3) cout << "trio" << endl;
  59.   else if (n == 4) cout << "full" << endl;
  60.   else cout << "parella" << endl;
  61. }
  62.  
  63. int main() {
  64.   int n;
  65.   cin >> n;
  66.   vector<int> v(5);
  67.   while (n != 0) {
  68.     read_vector(v);
  69.     result(operation(v));
  70.     --n;
  71.   }
  72. }
  73.  
  74. //JosepRivaille
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement