//============================================================ // HOMEWORK 0 //------------------------------------------------------------ // DUE DATE: Wednesday, 2/8/2006 //============================================================ // Modify the program below in three different ways // (NOTE save each version as a different name!): // // 1) Let the program print every other string in the // vector. That is, if the vector contains the string // // "Banana", "Apple", "Tree", "Frog", "Cat", "Blue" // // the program should print: // // "Banana", "Tree", "Cat" // // 2) Let the program print only the first three strings // in the list. If the user enter a list with fewer // than three entries, the program should end with // an error message // // 3) Add another vector to the program, called pList // that has exactly as many entries as sList. // Instead of strings, the user can enter decimal // numbers into this vector. If you want to, you can // interpret this as the prices of the items stored in // the vector sList. The program should go through all the // items in sList and print them with their prices. // That is if the two vectors contains the data // // "Banana", "Apple", "Tree", "Frog", "Cat", "Blue" // // and // // 1.23, 0.93, 832.23, 19.00, 11.45, 88.99 // // the program should print // // "Banana", 1.23, // "Apple", 0.93, // "Tree", 832.23, // "Frog", 19.00, // "Cat", 11.45, // "Blue", 88.99 // // //============================================================ // lab1.cpp // written by Detlef Ronneburger //============================================================ // // N O T E: The program already exists in your accounts // on the server. YOU DO NOT HAVE TO RETYPE THIS!!!! // //============================================================ #include #include #include using namespace std; int main() { int n; cout << "How long is the list? "; cin >> n; vector sList(n); for (int i=0; i < n; i++) { cout << "Enter next string: "; cin >> sList[i]; } for (int i=n-1; i >= 0; i--) { cout << sList[i] << "\n"; } }