List of all available Websheets
Viewing cpp/cs104/classes/preprocessor by redekopp@usc.edu. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
Property | Value |
---|---|
Description html markup shown to student | We want to see the output <tt>0 1 2 3 4 5</tt> from either approach of filling a <tt>deque<int></tt> at the back or from the front. <p>Both seem to have a problem in that they don't yield what we expect when we print the deque. Try both and then let your instructor show you how to use <strong>conditional compilation to try both approaches</strong> and add some debug statements that can easily removed.</p> <p><strong>Learning goal:</strong> </p> <ul><li>Use #define, #ifdef, #ifndef, #else, #endif </li> <li>Understand their use to have different code be compiled more easily.</li> </ul> |
Remarks Comments, history, license, etc. | Copied from problem cpp/cs104/classes/default-args (author: redekopp@usc.edu) Copied from problem cpp/cs104/classes/ctor-default (author: redekopp@usc.edu) Copied from problem cpp/cs104/classes/constructor_init (author: redekopp@usc.edu) |
Engine | |
Template / Reference solution |
using namespace std; int main() { \[ REDACTED \show: deque<int> q(5); // Fill at back approach //cout << "Fill at back" << endl; //for(int i=0; i<5; i++){ // q.push_back(i); //} // Fill from front approach cout << "Fill from front" << endl; for(int i=4; i>0; i--){ q.push_front(i); } ]\ for(size_t i = 0; i < q.size(); i++){ cout << q[i] << " "; } cout << endl; return 0; } |
C++ test suite json list of stdin/args tests e.g. [{"stdin":"hi", "args":["4", "5"]}, {"stdin":"noargs"}] to just run once with no input use [{}] | [{}] |
Is example? i.e., just a demo |
Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.