Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cs-142:triangle-function [2015/02/12 16:10] (current)
kseppi created
Line 1: Line 1:
 +<code cpp>
 +#include <​iostream>​
  
 +using namespace std;
 +
 +void line_o_stars(int length) {
 + for (int i = 0; i < length; i++) {
 + cout << "​*";​
 + }
 +}
 +
 +
 +void falling_triangle(int start, int decline) {
 + for (int i = start; i >= 0;) {
 + line_o_stars(i);​
 + cout << endl;
 + i -= decline;
 + }
 +}
 +
 +int main() {
 + int start, decline;
 +
 + cout << "I would like to make a lovely triangle for you.\n\n";​
 + cout << "​Please give the base: ";
 + cin >> start;
 + cout << "​Please give the decline: ";
 + cin >> decline;
 +
 + cout << "​\nHere it is!" << endl << endl;
 +
 + falling_triangle(start,​ decline);
 +
 + cout << "​\nPretty,​ huh!\n";​
 +
 + system("​pause"​);​
 + return 0;
 +}
 +</​code>​
cs-142/triangle-function.txt ยท Last modified: 2015/02/12 16:10 by kseppi
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0