// selection.cpp - selection sort demo // cmc, 5/22/2010 #include using namespace std; // pass-by-reference function to swap integers void swap(int &x, int &y) { int temp = x; x = y; y = temp; } // selection sort for integer array void sort(int a[], int n) { for (int i=n-1; i>0; i--) { int j = i; for (int k=0; k a[j]) j = k; if (j != i) swap(a[i], a[j]); } } // utility print function for integer array void pr(int a[], int n) { for (int i=0; i