I've gotten this down to where it prints the start of the diamond with the letter 'A' but it doesn't finish it. I can't seem to figure it out. please help.
this is what its suppose to look like when done.
For example, if the user enters 5, then the following diamond
comprised of 5 rows of uppercase letters is printed:
__A (2 spaces preceding first letter)
_ABC (1 space preceding first letter)
ABCDE (0 spaces preceding first letter)
_ABC (1 space preceding first letter)
__A (2 spaces preceding first letter)
*_* are spaces.
This is my code so far.
#include <cstdlib>
#include <iostream>
using namespace std ;
// Function getUserInput obtains an integer input value from the user.
// This function performs no error checking of user input.
int getUserInput ( )
{
int N ;
cout << endl << "Please enter a positive, odd integer value: " ;
cin >> N ;
cout << endl ;
return N ;
} // end getUserInput function
// Function printDiamond prints a diamond comprised of N rows of asterisks.
// This function assumes that N is a positive, odd integer.
void printDiamond ( int N )
{
char i=65;
// print top ~half of the diamond ...
for ( int row = 1 ; row <= (N/2 + 1) ; row ++ )
{
for ( int spaceCount = 1 ; spaceCount <= (N/2 + 1 - row) ; spaceCount ++ )
cout << ' ' ;
for ( int column = 1 ; column <= (2*row - 1) ; column ++ )
for ( char i=65; (i=i+N); i++)
cout << i;
cout << endl ;
} // end for loop
// print bottom ~half of the diamond ...
for ( int row = (N/2) ; row >= 1 ; row -- )
{
for ( int spaceCount = 1 ; spaceCount <= (N/2 + 1 - row) ; spaceCount ++ )
cout << ' ' ;
for ( int column = 1 ; column <= (2*row - 1) ; column ++ )
for ( char i=65; (i=i+N); i++)
cout << i;
cout << endl ;
} // end for loop