Use test_algorithm.cpp as an example. Write a C++ program using STL vector and algorithm to do the following: Create a vector of five items of type double with the values: 4.0, 1.5, 2.0, 3.0, 1.0 Print out the vector. Sort the vector. Print out the vector. Reverse the order of the vector. Print out the vector. Make the name of the file submitted, (requested, not required for Spring 99) my_algorithm.C or my_algorithm.cc or my_algorithm.cpp submit cs109 HW7 my_algorithm.C (or whatever extension)
Use test_list.cpp as an example. Write a C++ program using STL list to do the following: Create a list, L1, of five items of type double with the values: 4.0, 1.5, 2.0, 3.0, 1.0 Print out the list L1. Sort the list L1. Print out the list L1. Reverse the order of the list L1. Print out the list L1. Create a list, L2, of three items of type double with the following values: 7.5, 7.6, 7.7 Merge L2 onto the back of L1. Print out the list L1. ( should be L1 followed by L2 ) Print out the list L2. ( should be empty list ) Make the name of the file submitted, my_list.C or my_list.cc or my_list.cpp submit cs109 HW8 my_list.C (or whatever extension)
Open book. Open note. Bring copies of the homework you submitted. Be organized, the classroom is crowded and desktops are small. Multiple choice questions based on: lectures, reading assignments and homework. Exam covers book: 462-465 474-478 633 661-663 827-829 815-818 Exam covers homework: HW5-HW8 Exam covers lectures: 9,11-20
Omitted for spring 1999 semester
Write a C++ program to read (name,score) pairs and print out the name and best score. // find_max.cpp read find_max.dat into a vector // after the data is read in (print data as reading it) // print the name with the largest value (highest score) // // A simple main program is good enough // You may use a loop or STL to find the maximum value // test run your program using find_max < find_max.dat // // submit cs109 HW10 find_max.cpp or find_max.C or find_max.cc // // As usual, do it in C++ // Smaller is better // Simpler is better // Here is the file find_max.dat (the file does not contain "// ") // // Joe 3 // Jim 5 // Mary 4 // Mike 1 // John 6 // Jane 2
Omitted this semester. Put the extra effort into the project.
Open book. Open note. Bring copies of completed homework. Multiple choice questions based on lectures, reading assignments and homework. Exam covers book: all reading assignments Exam covers homework: all Exam covers lectures: all
Last updated 4/29/99