Hello, I am trying to create this ascii art using nested for loops,

***** ////////// *****
****  ////////\\  ****
***   //////\\\\   ***
**    ////\\\\\\    **
*     //\\\\\\\\     *
      \\\\\\\\\\

I tried doing a paper check and this is what I have so far...

*     /     \    * 
____________________
5     10    0    5
4     8     2    4
3     6     4    3
2     4     6    2
1     2     8    1
0     0     10   0

my brain tends to start sizzling when i get in-depth with nested for loops, any help would be greatly appreciated!

Okay try this algorithm for this you need to iterate 6 times to print all right so for that have a main loop stating to iterate 6 time and include the other iterations within that loop

I have given the pseudo code below

for (x=5 until x>=0 and deccrement x by 1 in each iteration){
 
   for(a=0 until a<=x and increment a by 1 in each iteration){
     print("*");
   }


   for(a=(x*2) until a>=0 and decrement a by 1 in each iteration){
     print("/");
   }


   for(a=(10-(x*2)) until a>=0 and decrement a by 1 in each iteration){
     print("\\");
   }  

   for(a=0 until a<=x and increment a by 1 in each iteration){
     print("*");
   } 
}

Edited 4 Years Ago by Zaad: Changed the algo

thanks for the help!
the only thing it needs now is the spaces added in, maybe i can figure that part out, thanks for the help tho!!

thanks for the help!
the only thing it needs now is the spaces,maybe i can figure that part out

Yeap it better, so that you would get a good practice :)

Edited 4 Years Ago by Zaad: n/a

This article has been dead for over six months. Start a new discussion instead.