List of all available Websheets
Viewing cpp/control/compare2 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 | Write a program that takes 2 integer inputs from the keyboard (separated by a space) and outputs the larger number first (on one line) followed by the smaller number. If they are equal just output<br> <tt>Equal!</tt> For example, if the input is <tt>74</tt> and <tt>38</tt> output: <pre> 74 38 </pre> If the input is <tt>23</tt> and <tt>23</tt> output: <pre> Equal! </pre> |
Public permissions | |
Remarks Comments, history, license, etc. | Copied from problem cpp/control/letter_grade (author: redekopp@usc.edu) Copied from problem cpp/control/nth (author: daveagp@gmail.com) |
Engine | |
Template / Reference solution |
using namespace std; int main() { \[ int val1, val2; // values cin >> val1 >> val2; if(val1 > val2){ cout << val1 << endl; cout << val2 << endl; } else if(val2 > val1){ cout << val2 << endl; cout << val1 << endl; } else { cout << "Equal!" << 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": "74 38"}, {"stdin": "23 23"}, {"stdin": "-9 -3"} ] |
Solution visibility |
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'.