There are 24 questions and a total of 100 points. The multiple choice questions count 3 points each. Circle the letter of your choice.
Multiple choice Questions 1 - 15: The correct answer is indicated on your returned exam.
1 it: it.o thing.o 2 g++ it.o thing.o -R/opt/gcc-3.2/lib 3 4 thing.o: thing.C thing.h 5 g++ thing.C -c 6 7 it.o: it.C thing.h 8 g++ it.C -c 9 10 clean: 11 rm -rf *.o a.out it
An executable named a.out
2 g++ it.o thing.o -R/opt/gcc-3.2/lib -o that
Causes an Error, because there is no rule to make target `thing' Actual behaviour: From default rules it tries to make thing by linking relocatable thing.o into an executable. Then the error message is "Undefined symbol main".
Compiles it.C (which presumably includes thing.h) to make relocatable code file it.o
11 - any previously compiled .o files are removed as are go and a.out if they exist 8 - compile it.o -- after examining line 1 it sees it must first build target it.o 5 - compile thing.o -- after examining line 1 it sees it must first build thing.o (above two can be in either order) 2 - call compiler to just link the thing.o and it.o into the executable (named `a.out' or `that')
main() { string s, maxval; vector<string> A; vector<string>::iterator j; while (cin >> s ) A.pushback( s ); maxval = *(A.begin()); for ( j = A.begin() + 1; j != A.end(); ++j ) if ( *j > maxval ) maxval = *j;
main() { string s, maxval; vector<string> A; int j; // vector<string>::iterator j; while (cin >> s ) A.pushback( s ); maxval = A[0]; // *(A.begin()); for ( j = 1; j != A.size(); ++j ) // for ( j = A.begin() + 1; j != A.end(); ++j ) if ( A[j] > maxval ) maxval = A[j]; // if ( *j > maxval ) maxval = *j;
It is a generic function taking a start and stop iterator. it reverses the positions of elements in subrange of the container from start (inclusive) to stop(exclusive).See SGI documentation and (for instance) text palindrome_type1 example.
enum honor {non_honor, jack, queen, king, ace}; honor honors( Card & c ) { // solution: switch (c.Rank()){ case 1: return ace; case 11: return jack; case 12: return queen; case 13: return king; default: return non_honor; } }
See course palindrome code directory or text pg 127 palindrome example.