Advertisement
hurmawe

8.3

May 19th, 2022
683
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <vector>
  2. #include <ioastream>
  3. using namespace std;
  4.  
  5. int max_elem(const vector<int> &a, const int &lenght)
  6. {
  7.     int max_elem = -100;
  8.     for (int i = 0; i < lenght; i++)
  9.     {
  10.         if(a[i]> max_elem)
  11.             max_elem = a[i];
  12.     }
  13.     return max_elem;
  14. }
  15.  
  16. int main()
  17. {
  18. vector<int> array = { 6, 9,66,785,632,569,56,654,2,0, 31,23,33};
  19.  
  20. cout << max_elem(array, array.size())<< endl;
  21. }
Advertisement
RAW Paste Data Copied
Advertisement