Accelerated C++ Student Grading
I’m teaching myself C++ with Koenig and Moo’s “Accelerated C++” at the moment.
I haven’t found a book such slow going since struggling through Kant’s “Introduction to the Metaphysics of Morals” as an undergraduate. I should perhaps have chosen a gentler introduction to programming but, from what I have read elsewhere, this is regarded as the best book on the language and I’d rather learn slowly from the best than race through easier texts, picking up bad habits that will later need to be unlearned.
Exercise 5-2 asks you to compare the performance of two student-grading programs, one using vectors, the other lists, against records of different lengths.
I’ve generated some data files to represent student records and am sharing them here in case anyone else wants to use them. They are plain text files. Each line gives a name followed by a list of 10 numbers between 30 and 90 that represent the student’s grades. (NB assuming a pass mark of 60, about half the students fail their course using this data set).
There are four files listing 10, 100, 1000 and 10000 sets of names and results. Download the tarball (linux/unix) containing all four and unpack it with tar -xvzf students.tgz. I’ve also created a zip file for Windows users. Mac users I believe should be able to handle either version. Please let me know if it doesn’t work.
Feel free to use them and save yourself the hassle of generating your own.
(UPDATED: 22 July)
July 29th, 2005 at 4:11 am
Tim,
Good luck in your studies. I had noticed you were a little quiet on your blog and kept seeing your del.icio.us links to C++ resources and figured you’ve been busy at it.
Corey
July 29th, 2005 at 10:31 am
Cheers Corey. You’re right - I’ve been focussing on that rather than the blog. I’m starting a course in October and I’m trying to get a good head start on it. Thanks for the best wishes.
July 4th, 2008 at 6:43 pm
I recently started reading the book also and I’ve come up to this exercise. I am kinda stuck though, how would I insert the students names? The book hasn’t cover file stream yet so i’m not entirely sure how to test the program.
How did you do this exercise?
Ezekiel
July 5th, 2008 at 4:28 pm
Hi Ezekiel,
I’ve just checked my old notes and I used filestreams to insert the students names. (The code is horrible so I won’t share it!). I don’t have a copy of the book lying around so I can’t recall the original question but I do remember being annoyed that sometimes questions seemed to require knowledge not covered until later chapters. Think of it as an incentive to read ahead! Alternatively you could always hard code the data into your application if you really don’t want to use file streams but that seems a little pointless to me.
Good luck with the book. It’s an excellent introduction to C++.