#include #include #include //for string using namespace std; int main() { string a[] = { //an array of strings, stops on the #1 subway "242nd Street", //Van Cortlandt Park "238th Street", "231st Street", "225th Street", //Marble Hill "215th Street", "207th Street", "Dyckman Street", "191st Street", "181st Street", "168th Street", "157th Street", "145th Street", "136th Street", //City College "125th Street", //above ground "116th Street", //Columbia University "110th Street", //Cathedral Parkway "103rd Street", "96th Street", "86th Street", "79th Street", "72nd Street", "66th Street", //Lincoln Center "59th Street", //Colubus Circle "50th Street", "42nd Street", //Times Square "34th Street", //Penn Station "28th Street", "23rd Street", "18th Street", "14th Street", "Christopher Street", //Stonewall "Houston Street", "Canal Street", "Franklin Street", "Chambers Street", "WTC Cortlandt", "Rector Street", "South Ferry" }; int n {size(a)}; //the number of stops on the #1 subway cout << "Type 1 to go downtown, 2 to go uptown: "; int direction {0}; cin >> direction; if (direction == 1) { cout << "Going downtown on the #1, from " << a[0] << " to " << a[n-1] << ":\n\n"; for (int i {0}; i < n; ++i) { cout << a[i] << "\n"; } } else if (direction == 2) { cout << "Going uptown on the #1, from " << a[n-1] << " to " << a[0] << ":\n\n"; for (int i {n-1}; i >= 0; --i) { cout << a[i] << "\n"; } } else { cerr << "Bad response " << direction << ", should have been 1 or 2.\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; }