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

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.
PropertyValue
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 remove
Engine
Template / Reference solution
 
#include <iostream>
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 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'.