Author Topic: simple c++ question  (Read 1431 times)

0 Members and 1 Guest are viewing this topic.

Offline Kosh

  • A year behind what's funny
  • 210
Our assignment is to make the following to appear on screen:

         *
      * * *
   * * * * *         
* * * * * * *
      * * *
      * * *
      * * *

Other than brute forcing it, is there another way with loops? I was thinking nested loops but I'm not entirely clear on how to increment this.....
"The reason for this is that the original Fortran got so convoluted and extensive (10's of millions of lines of code) that no-one can actually figure out how it works, there's a massive project going on to decode the original Fortran and write a more modern system, but until then, the UK communication network is actually relying heavily on 35 year old Fortran that nobody understands." - Flipside

Brain I/O error
Replace and press any key

 

Offline Spicious

  • Master Chief John-158
  • 210
Try thinking about how the number of *s per line changes as you go down and also the number of spaces before the *s start on each line. Of course, this is only worth doing if the arrow size is variable; otherwise, you might as well just print a string literal.

 

Offline blackhole

  • Still not over the rainbow
  • 29
  • Destiny can suck it
    • Black Sphere Studios
#include <iostream>

int main()
{
cout << "         *\n
      * * *\n
   * * * * *\n         
* * * * * * *\n
      * * *\n
      * * *\n
      * * *\n";
return 0;
}

If an assignment is only going to take you 15 seconds to brute force, you might as well brute force it.

 

Offline Kosh

  • A year behind what's funny
  • 210
Thanks.
"The reason for this is that the original Fortran got so convoluted and extensive (10's of millions of lines of code) that no-one can actually figure out how it works, there's a massive project going on to decode the original Fortran and write a more modern system, but until then, the UK communication network is actually relying heavily on 35 year old Fortran that nobody understands." - Flipside

Brain I/O error
Replace and press any key