#include #include #include //for class string using namespace std; //Search an array for a given value. int main() { //The New York Knickerbockers, in order of descending height (in meters) string a[] { //an array of 18 strings "Mitchell Robinson", //2.13 m "Ariel Hukporti", //2.13 m "Jericho Sims", //2.08 m "Jacob Toppin", //2.03 m "Pacome Dadiet", //2.03 m "Keita Bates-Diop", //2.03 m "Precious Achiuwa", //2.03 m "Julius Randle", //2.03 m "Kevin McCullar", //2.01 m "OG Anunoby", //2.01 m "Mikal Bridges", //1.98 m "Landry Shamet", //1.93 m "Donte DiVincenzo", //1.93 m "Josh Hart", //1.93 m "Cameron Payne", //1.91 m "Tyler Kolek", //1.91 m "Jalen Brunson", //1.88 m "Miles McBride" //1.88 m }; int n {size(a)}; //how many Knicks cout << "Please type a name (First name space Last name): "; string name; //Automatically puts "" into name. getline(cin, name); //Put the entire line the user types into name. cout << "The name you typed was '" << name << "'.\n"; for (int i {0}; i < n; ++i) { if (a[i] == name) { cout << name << " is Knick number " << i+1 << " of " << n << " in height.\n"; return EXIT_SUCCESS; } } //Arrive here if we didn't find the name we were looking for. cerr << "Sorry, " << name << " is not a Knick.\n"; return EXIT_FAILURE; }