COMP2004 Programming Practice
2002 Summer School

Week 6 Friday Tutorial Exercises

  1. Enter the example find_if code from today's lecture. You can use this line to read in int values from cin:
    copy(istream_iterator<int>(cin), istream_iterator<int>(), back_inserter(l));
    Modify this code so that it outputs the first and the second negative numbers in the list.

  2. Modify your solution to Question 1 so that all of the negative numbers in the list are output.

  3. Modify your solution to Question 2 so that the is_negative() function isn't needed. (Hint: Try using bind2nd().)

  4. Rewrite the split() function from Question 7 of the Week 1 Friday tutorial so that it uses the generic algorithms from #include <algorithm> instead of the methods of the string class.

  5. Experiment with the rest of the code examples from the lecture, make sure you understand why they do what they do.

  6. Continue working on your Assignment 3 solution.