Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

ASCII diamond problem

$
0
0
Hi, I am currently working on making an ASCII diamond that looks like this:
    XX
   XXXX
  XXXXXX
 XXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
 XXXXXXXX
  XXXXXX
   XXXX 
    XX


Right now the im trying to do it using a max of three for loops, each loop printing one character at a time. My code looks like this currently.

#include iostream

using namespace std;

int maxRows = 10;
int width = maxRows / 2;

int main()
{
     //main loop
     for(int rows = -(maxRows / 2); rows <= maxRows / 2; rows++)
     {
          //whitespace loop
          for(int white = 0; white < abs(row) - 1; white++)
          {
               cout<<" ";
          }

          //X loop this is where I am confused, I am not sure what logic I need to use
          for(int X = //the rest im not sure)
          {
               cout<<"X";
          }

          if(rows = 0)
          {
               rows++;
          }
     }

     return 0;

}


Any help or suggestions would be appreciated, I cannot think of what logic will complete this loop the way I want.

Edit:
The Diamond is supposed to look like this when output to the console
    XX
   XXXX
  XXXXXX
 XXXXXXXX
XXXXXXXXXX
XXXXXXXXXX
 XXXXXXXX
  XXXXXX
   XXXX
    XX


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>