//pointersort.cpp //sorting by moving pointers, not the data #include //cout, endl using namespace std; const int MAX = 10; void swap(int* &p, int* &q) // swaps addresses stored in p and q {int* temp; temp = p; p = q; q = temp; return; } //end swap void bubblesort(int* list[], int size) //list is an array of pointers //size is the number of items in list {int end=size-1; int i; for (end=size-1; end>=1; end--) for (i=0; i<=end-1; i++) if ( *list[i] > *list[i+1] ) swap(list[i],list[i+1]); return; } // end bubblesort int main() { int datalist[MAX]={100,37,26,48,2}; int* pointerlist[MAX]; int numitems=5; //array can hold MAX, //only use numitems int j; for (j=0; j