#include #include #include //for numeric_limits using namespace std; //The 2021 median household income for each state. //https://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_income int main() { int a[] { 53913, //Alabama 77845, //Alaska 69056, //Arizona 52528, //Arkansas 84907, //California 82254, //Colorado 83771, //Connecticut 71091, //Delaware 63062, //Florida 66559, //Georgia 84857, //Hawaii 66474, //Idaho 72205, //Illinois 62743, //Indiana 65600, //Iowa 64124, //Kansas 55573, //Kentucky 52087, //Louisiana 64767, //Maine 90203, //Maryland 89645, //Massachusetts 63498, //Michigan 77720, //Minnesota 48716, //Mississippi 61847, //Missouri 63249, //Montana 66817, //Nebraska 66274, //Nevada 88465, //New Hampshire 89296, //New Jersey 53992, //New Mexico 74314, //New York 61972, //North Carolina 66519, //North Dakota 62262, //Ohio 55826, //Oklahoma 71562, //Oregon 68957, //Pennsylvania 74008, //Rhode Island 59318, //South Carolina 66143, //South Dakota 59695, //Tennessee 66962, //Texas 79449, //Utah 72431, //Vermont 80963, //Virginia 84247, //Washington 51248, //West Virginia 67125, //Wisconsin 65204 //Wyoming }; int n {size(a)}; //number of elements in array for (int i {0}; i < n; ++i) { //Let smallest be the subscript of the smallest element //currently in the array. int smallest {0}; for (int j {1}; j < n; ++j) { if (a[j] < a[smallest]) { smallest = j; } } //Output the smallest value and erase it. cout << a[smallest] << "\n"; a[smallest] = numeric_limits::max(); //biggest possible int } return EXIT_SUCCESS; }