#include #include #include using namespace std; //Data retrieved from https://worldpopulationreview.com/state-rankings/snowiest-state int main() { //struct snowfall { //Top 10 Snowiest States //string a; //name of state // double inches; //snowfall in inches //int station, //National Centers for Environmental Information (NCEI compiling station to compute snowfall total double a[] { 72.8, //{Alaska, 72.8, 28}, 59.9, //{New Hampshire, 59.9, 11}, 58.4, //{Vermont, 58.4, 10}, 57.6, //{Maine, 57.6, 15}, 51.3, //{New York, 51.3, 22}, 44.3, //{Massachusetts, 44.3, 11}, 43.5, //{Michigan, 43.5, 26}, 38.7, //{Connecticut, 38.7, 8}, 37.8, //{Minnesota, 37.8, 32}, 36.9 //{Colorado, 36.9,33} }; int n {size(a)}; //the number of elements in the array for (double *p {a+n-1}; p > a; --p){ //Start with pointing to the last element for (double *q {a}; q < p; ++q) { if (q[0] > q[1]){ //q[0] should be less than or equal to q[1]. //if q[0] and q[1] are in the wrong order, double temp {q[0]};//swap the values of q[0] and q[1]. q[0] = q[1]; q[1] = temp; } } } for (double *p {a}; p < a+n; ++p) { cout << setw(2) << p-a+1 << " " << *p << "\n"; } return EXIT_SUCCESS; }