//************************************************************ // Solutions to Homework 0 //************************************************************ // lab1.cpp //************************************************************ // Modify the program so that it reads at least three // string from the user, stores them in the vector sList // and then prints out the first three #include #include #include using namespace std; int main() { int n; cout << "How long is the list? "; cin >> n; if (n < 3) { cout << "Need at least three elements in the list!\n"; return 0; //leaving the program } vector sList(n); for (int i=0; i < n; i++) { cout << "Enter next string: "; cin >> sList[i]; } //now print out the first 3 elements: for (int i=0; i < 3; i++) { cout << sList[i] << "\n"; } }