List of all available Websheets
Viewing cpp/while/reverse 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 | <p>Given a non-negative number, print that number in reverse (e.g. if they enter <tt>123</tt> output <tt>321</tt>). <p>If the number is negative, simply print <tt>error</tt>.</p> <p>Keep in mind that there are a few ways to do this, but we suggest you consult your idioms for isolating digits which might also help you on your homework.</p> <p>Important: 0 may be an "edge case". Make sure you print it out appropriately!</p> |
Remarks Comments, history, license, etc. | Copied from problem cpp/cs102/practice6/tippingCalculator (author: jmell@usc.edu) Copied from problem cpp/cs102/practice5/computingPie (author: jmell@usc.edu) |
Engine | |
Template / Reference solution |
using namespace std; int main() { long num; cout << "Input a number: "; cin >> num; cout << "Answer: "; if (\[ REDACTED ]\) { \[ REDACTED ]\ } else if (\[ REDACTED ]\ ) { cout << "error" << endl; } else { \[ REDACTED ]\ 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 [{}] | [ {"stdin":"0", "args":[]}, {"stdin":"-438", "args":[]}, {"stdin":"123456789", "args":[]}, {"stdin":"11210", "args":[]} ] |
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'.