Name: ________________________________

Honor Code Acknowledgment: ___________________


Random Quiz # 4

CPS 100E, Fall 1996

Due: September 19


Problem 1: Gemini Rising (5 points)

Write a function that "doubles" a vector by replacing every element in the vector with two identical elements. For example, doubling the following vector of strings
"apple""orange""pear"

yields the vector below

"apple""apple""orange" "orange""pear""pear"

Complete the function below the following header. For full credit you cannot define another Vector variable, you must double "in place" using only the parameter list. Assume that list is full (in the example above, before doubling list would have room for exactly three strings.)

void CloneTwo(Vector<string> & list) // precondition: list contains list.Length() elements, call this x // conceptually, list = (a,b,c) // postcondition: list contains 2*x elements, // conceptually list = (a,a,b,b,c,c)