Advertisement
hurmawe

8.4

May 19th, 2022
688
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <vector>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5.  
  6. bool rep(const vector< int> & a, const int &lenght)
  7. {
  8.     bool rep = 0;
  9.     for (int i = 0; i < lenght; i++)
  10.     {
  11.         int count = 0;
  12.         for (int j = i; j < lenght; j++)
  13.         {
  14.             if (a[i] == a[j])
  15.             {
  16.                 count++;
  17.                 if (count == 2)
  18.                     rep = 1;
  19.             }
  20.         }
  21.     }
  22.     return rep;
  23. }
  24. int main()
  25. {
  26. vector<int> array = { 6, 9,66,785,632,569,56,654,2,0, 31,23,33};
  27. cout <<"Задание 8: "<< rep(array,array.size()) << endl;
  28. }
Advertisement
RAW Paste Data Copied
Advertisement