List of all available Websheets
Viewing cpp/classes/location_eq by daveagp@gmail.com. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
Property | Value |
---|---|
Description html markup shown to student | Comparing <tt>struct</tt>s. |
Public permissions | |
Engine | |
Template / Reference solution |
using namespace std; struct Location { // define a new data type, Location int row; // each Location has a row int col; // each Location has a col }; int main() { cout << boolalpha; Location home; // construct a Location home.row = 5; home.col = 10; Location north_of_home = home; // copy it north_of_home.row -= 1; Location home_again = north_of_home; // copy it home_again.row += 1; // compare them \[ // if you did this a lot, you might want to make a function! cout << (home.row == north_of_home.row && north_of_home.row == north_of_home.col) << endl; cout << (home.row == home_again.row && home.col == home_again.col) << endl; \show: cout << (home == north_of_home) << endl; cout << (home == home_again) << endl; ]\ } |
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 [{}] | [ {} ] |
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'.