Advertisement
Savonarolla

Untitled

Dec 20th, 2020
524
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.81 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <deque>
  4. #include <iomanip>
  5. #include <vector>
  6. #include <random>
  7. #include <algorithm>
  8.  
  9. using namespace std;
  10.  
  11.  
  12.  
  13. void solve(vector<int> &array, vector<int> &res)
  14.     {
  15.        for (int i = 0; i < array.size(); i++)
  16.            {
  17.                vector<bool> flag;
  18.                int newSize = array.size() - i;
  19.                flag.resize(newSize);
  20.                for (int j = 0; j < array.size() - i; j++)
  21.                    {
  22.                        int z = 0;
  23.                        if (array[i] < array[j])
  24.                            {
  25.                                break;
  26.                            }
  27.                        if (array[i] > array[j])
  28.                            {
  29.                                flag[z++] = true;
  30.                            }
  31.                        if (array[j] == array.front())
  32.                            {
  33.                                int newSize2 = 0;
  34.                                for (int x = 0; x < newSize; x++)
  35.                                    {
  36.                                        if (flag[x])
  37.                                            {
  38.                                                newSize2++;
  39.                                            }
  40.                                    }
  41.                            if (newSize2 == newSize)
  42.                                {
  43.                                    res.push_back(array[i]);
  44.                                    break;
  45.                                }
  46.                            }
  47.                    }
  48.            }
  49.     }
  50.  
  51. int main()
  52.     {
  53.  
  54.         vector<int> V = {75,47,42,56,13,55};
  55.         vector<int> res;
  56.  
  57.         solve(V,res);
  58.  
  59.         for (int i = 0; i < res.size(); i++)
  60.             {
  61.                 cout << res[i] << '\t';
  62.             }
  63.     }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement