#include #include #include void quickSort (apvector &list, int first, int last); struct item { int id; int inv; }; struct storeType { apvector list; int number; }; ostream & operator<< (ostream & Out, const infoType &temp) { Out << temp.id << " " << temp.inv << endl; return Out; } int main (void) { storeType inventory; ifstream infile ("file50.txt",ios::in); int n = 0; infile >> n; inventory.list.size(n); inventory.number = n; apvector list(n); for (int g = 0;g < n;g++) { int y,z; infile >> y;infile >> z; inventory.list[g].id = y; inventory.list[g].inv = z; list[g]=y; } quickSort(list,0,n-1); return 0; } void quickSort (apvector &list, int first, int last) { int g = first, h = last; int midIndex, dividingValue, temp; midIndex = (first + last) / 2; dividingValue = list[midIndex]; do { while (list[g] < dividingValue) g++; while (list[h] > dividingValue) h--; if (g <= h) { swap(list[g], list[h]); g++; h--; } } while (g < h); if (h > first) quickSort (list,first,h); if (g < last) quickSort (list,g,last); }