List of all available Websheets
Viewing cpp/control/flag 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 | The official flag of CSCI 103 is a right triangle pointing up-left, with <code>n</code> rows and <code>n</code> columns, made out of backslashes, where <code>n</code> is a command-line argument. Write a program to print it out for any positive integer <code>n</code>: for example <code>./flag 5</code> should print out <pre> \\\\\ \\\\ \\\ \\ \ </pre> This tests two things: escaping in strings, and nested loops. |
Public permissions | |
Engine | |
Template / Reference solution |
using namespace std; int main() { int n; cin >> n; for (int i=0; \[i<n; i++]\) { for (int j\[=0; j<n-i; j++]\) { cout << \["\\"]\; } cout << \[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 [{}] | [ {"stdin": "5", "args": ""}, {"stdin": "10", "args": ""}, {"stdin": "1", "args": ""} ] |
Solution visibility | |
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'.