Illustrating the generic swap algorithm: swap two integers : swap « STL Algorithms Modifying sequence operations « C++






Illustrating the generic swap algorithm: swap two integers

 
 


#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  int high = 250, low = 0;

  swap(high, low);

  cout << high << " ";
  cout << low;


  return 0;
}

/* 
0 250
 */        
  








Related examples in the same category

1.Illustrating the generic swap algorithm
2.Swap elements at locations 0 and 1 of an array
3.Swap second and fourth element in a vector