GastonFontenla

N3P1 - Generala

Sep 1st, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. vector <int> generala(int a, int b, int c, int d, int e)
  6. {
  7.     vector <int> dados = {a, b, c, d, e}, freq(7, 0);
  8.  
  9.     for(int i=0; i<dados.size(); i++)
  10.         freq[dados[i]]++;
  11.  
  12.     vector <int> res(10, 0);
  13.     for(int i=1; i<=6; i++)
  14.         res[i-1] = freq[i]*i;
  15.  
  16.     sort(dados.begin(), dados.end());
  17.  
  18.     vector <int> x = {1, 2, 3, 4, 5},
  19.                  y = {2, 3, 4, 5, 6},
  20.                  z = {1, 3, 4, 5, 6};
  21.  
  22.     if(dados == x || dados == y || dados == z)
  23.         res[6] = 20;
  24.  
  25.     for(int i=1; i<=6; i++)
  26.         for(int j=1; j<=6; j++)
  27.             if(freq[i] == 2 && freq[j] == 3)
  28.                 res[7] = 30;
  29.  
  30.     for(int i=1; i<=6; i++)
  31.         if(freq[i] >= 4)
  32.             res[8] = 40;
  33.  
  34.     for(int i=1; i<=6; i++)
  35.         if(freq[i] == 5)
  36.             res[9] = 50;
  37.  
  38.     return res;
  39. }
  40.  
  41. /**
  42. //Función main auxiliar para testear
  43. int main()
  44. {
  45.     int a, b, c, d, e;
  46.     cin >> a >> b >> c >> d >> e;
  47.     auto res = generala(a, b, c, d, e);
  48.     for(auto i:res)
  49.         cout << i << " ";
  50.     cout << endl;
  51. }
  52. **/
Advertisement
Add Comment
Please, Sign In to add comment