List of all available Websheets
Viewing cpp/functions/draw-angled-line 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 | <p>Define a function <tt>drawAngledLine</tt> that takes a <strong>double</strong> representing angle (in degrees) and an <strong>integer</strong> representing the number of vertical rows and draws a line for the given number of rows and at the given angle (relative to the vertical downward line).</p> <p>For example, if the user passed <tt>60.0</tt> and <tt>5</tt> you should output:</p> <p>If the user passed <tt>30.0</tt> and <tt>8</tt> you should output:</p> |
Public permissions | |
Remarks Comments, history, license, etc. | Copied from problem cpp/functions/draw_square (author: redekopp@usc.edu) Originally by Mark Redekopp (redekopp@usc.edu) and Dave Pritchard (daveagp@gmail.com) |
Engine | |
Template / Reference solution |
using namespace std; \[ void ]\ drawAngledLine (\[ double angle, int nrows ]\) { \[ for(int i=1; i <= nrows; i++){ int cols = (int)floor(i*tan(M_PI*angle/180.0)); for(int j=0; j < cols-1; j++){ cout << " "; } cout << "*" << endl; } ]\ } |
C++ test suite See manual | [ ["check-function", "drawAngledLine", "void", ["double", "int"]], ["call-function", "drawAngledLine", ["60.0", "5"]], ["call-function", "drawAngledLine", ["30.0", "8"]] ] |
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'.