Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const short SECTOR_MIN = 1; // The lowest sector number
- const short SECTOR_MAX = 7; // The max sector number
- const short WEIGHT_MIN = 25; // The minimum weight of a pile of trash
- const short WEIGHT_MAX = 500; // The max weight of a pile of trash
- const short GUILT_MIN = 100; // The min guilt value that a person can have
- const short GUILT_MAX = 10000; // The max guilt value a person can have
- const short SIZE = 15; // The array sizes
- struct guilt
- {
- string name;
- short guilt;
- };
- struct trash
- {
- short sector;
- short weight;
- };
- // Description: The bubble_sort() function will sort the values of an
- // array from least to greatest.
- // Pre: The > operator must be defined.
- // Post: The functions will be sorted from greatest to least.
- template <typename T1, typename T2, typename T3>
- void bubble_sort(T1 array[], T2 arr_elem1, T3 arr_elem2, const short SIZE)
- {
- T2 elem1_temp; // The temporary holding place for array element2
- T3 elem2_temp; // The temporary holding place for array element1
- for(int j = 0; j <= SIZE - 1; j++)
- {
- for(int i = 0; i <= SIZE - 1; i++)
- {
- if(array[i+1].arr_elem2 > array[i].arr_elem2)
- {
- elem1_temp = array[i].elem1_temp;
- elem2_temp = array[i].elem2_temp;
- array[i].arr_elem1 = array[i+1].arr_elem1;
- array[i].arr_elem2 = array[i+1].arr_elem1;
- array[i+1].arr_elem1 = elem1_temp;
- array[i+1].arr_elem2 = elem2_temp;
- }
- }
- }
- }
- // Description: The my_rand() function will put out a random number
- // between the lower and upper limit.
- // Pre: None
- // Post: The function will return a random number.
- short my_rand(const short lower_lim, const short upper_lim);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement