Not logged in. Log in with GitHub. About Websheets.

List of all available Websheets


Viewing cpp/classes/examples/location_eg by redekopp@usc.edu. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
PropertyValue
Description
html markup
shown to student
 
An example of <tt>struct</tt>.
Public permissions remove
Engine
Template / Reference solution
 
#include <iostream>
#include <iomanip>
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
};
void print_location(Location loc); // TODO
int main() {
\[
\show:
   Location home; // construct a Location
   home.row = 5;
   home.col = 10;
   Location north_of_home = home; // copy it
   north_of_home.row -= 1;
   print_location(home);
   print_location(north_of_home);
]\
}
void print_location(\[Location loc]\) {
   cout << "row " << \[ loc.row  ]\ << ", column " << \[ loc.col  ]\ << 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 remove
Is example?
i.e., just a demo
remove


Optional properties:

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'.