123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
#include <iostream> #include <string> #include <algorithm> using namespace std; const int SIZE = 3; struct part_rec { string partnum; float value; int quantity; }; void deletePart(part_rec arr[], string partnum) { for(int i = 0; i < SIZE; i++) { if(arr[i].partnum == partnum) { for(int r = i; r < SIZE; r++) { arr[r] = arr[r + 1]; } }else if(arr[i].partnum != partnum) { continue; } } } void sort(part_rec arr[]) { string first = " ", temp = " ", int i,j; for (i = 0; i < SIZE; i++) { for (j=1; j<=i; j++) { if (arr[j] < arr[first]) first = j; } temp = arr[first].partnum; arr[first].partnum = arr[i].partnum; arr[i].partnum = temp; } return; } void main() { part_rec arr[SIZE] ={{"5", 10, 2}, {"3", 16, 5}, {"7", 11, 3}}; //sort(arr); cout << arr[0].partnum; cout << arr[1].partnum; cout << arr[2].partnum; system("pause"); }