A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/d3/d61/vector__important__functions_8cpp_source.html below:

TheAlgorithms/C++: others/vector_important_functions.cpp Source File

13 int

arr[] = {10, 20, 5, 23, 42, 15};

14 int

n =

sizeof

(arr) /

sizeof

(arr[0]);

15

std::vector<int> vect(arr, arr + n);

17

std::cout <<

"Vector is: "

;

18 for

(

int

i = 0; i < n; i++) std::cout << vect[i] <<

" "

;

21

std::sort(vect.begin(), vect.end());

23

std::cout <<

"\nVector after sorting is: "

;

24 for

(

int

i = 0; i < n; i++) std::cout << vect[i] <<

" "

;

27

std::reverse(vect.begin(), vect.end());

29

std::cout <<

"\nVector after reversing is: "

;

30 for

(

int

i = 0; i < 6; i++) std::cout << vect[i] <<

" "

;

32

std::cout <<

"\nMaximum element of vector is: "

;

33

std::cout << *max_element(vect.begin(), vect.end());

35

std::cout <<

"\nMinimum element of vector is: "

;

36

std::cout << *min_element(vect.begin(), vect.end());

39

std::cout <<

"\nThe summation of vector elements is: "

;

40

std::cout << accumulate(vect.begin(), vect.end(), 0);


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4