swap_ranges() Function in C++

This C++ program demonstrates the swap_ranges() algorithm. The program creates two arrays of integers and swaps the elements by passing iterators to the range of elements to be swapped into the function swap_ranges. Here is the source code of the C++ program which demonstrates the swap_ranges() algorithm. The C++ program is successfully compiled and run … Read more

advertisement

swap() Function in C++

This C++ program swaps elements of containers using swap() algorithm. The program initializes the elements of the container to be swapped, the containers are passed to the function by reference and the elements of the containers are swapped. Here is the source code of the C++ program which swaps elements of two container using swap() … Read more

advertisement

Swap Values using swap() in C++

This C++ program swaps values using swap() algorithm. The elements are passed to the function as parameters by reference and the values of the elements are then swapped by the function swap() defined in algorithm library. Here is the source code of the C++ program which swaps values using swap() algorithm. The C++ program is … Read more

advertisement

prev_permutation() in C++

This C++ program demonstrates the prev_permutation algorithm. The string is first sorted in reverse manner by passing the reverse iterators to the sort function and then permuted using prev_permutation. The prev_permutation takes iterators to the beginning and end of the string to be permuted and overwrites the value of the string with its previous lexicographic … Read more

advertisement

next_permutation() in C++

This C++ program demonstrates the next_permutation algorithm. The program first sorts the string and then permutes the entire string. The next_permutation takes iterators to the beginning and end of the string to be permuted and overwrites the value of the string with next lexicographic permutation. The function returns true if next_permutation is available otherwise returns … Read more

advertisement

lexicographical_compare() in C++

This C++ program demonstrates the lexicographical_compare() algorithm. The lexicographical_compare function takes five parameters – the four parameters are begin and end iterators to the two containers and the fifth parameter is a predicate. The predicate we are using is equal_to which is defined in the functional library. Here is the source code of the C++ … Read more

advertisement

max_element() Function in C++

This C++ program demonstrates the max_element algorithm on a container. The max_element() function has two overloaded forms – one with a compare predicate as the third parameter and another without it. The program demonstrates both of the overloaded forms where one prints the element with maximum value in a vector and another using a compare … Read more

advertisement

max() Function in C++

This C++ program prints maximum of two values using max algorithm. The function takes two objects as the parameters by const reference and the third parameter is optional which is a predicate. The predicate can be used for objects which can not be compared like primitive datatypes and hence can be compared on the basis … Read more

advertisement

min_element() Function in C++

This C++ program demonstrates the min_element algorithm on a container. The min_element() function has two overloaded forms – one with a compare predicate as the third parameter and another without it. The program demonstrates both of the overloaded forms where one prints the element with minimum value in a vector and another using a compare … Read more

advertisement

min() Function in C++

This C++ program prints minimum of two values using min algorithm. The function takes two objects as the parameters by const reference and the third parameter is optional which is a predicate. The predicate can be used for objects which can not be compared like primitive datatypes and hence can be compared on the basis … Read more

advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.