Ok, so I want to create an alternate way of creating this:
*________*
**______**
***____***
****__****
**********
****__****
***____***
**______**
*________*
Note: The right side is supposed to lookjust like the left side.
Note 2: Replacing the underscores with asterisks(*)
This is the code I have so far, but I want to know of other ways to do it, I`d be grateful if you helped me.
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
using namespace std;
const char symbol('*');
const char space(' ');
int main(int argc, char *argv[]){
string in;
stringstream ss;
int n, x;
x=1;
do {
cout << "Enter an integer(an odd number): ";
getline(cin,in);
ss.clear();
ss.str(in);
} while (!(ss >> n) || (n < 3) || (!(n & 1)));
char *symbols = new char[n + 1], *p = symbols + n - 1, it
*spaces = new char[(n * 2) - 1], *q = spaces;
fill(symbols, symbols + n, symbol);
symbols[n] = '\0';
fill(spaces, spaces + (n * 2) - 2, space);
spaces[(n * 2) - 1] = '\0';
do {
cout << p << q << p << endl;
if (p == symbols) x = -x;
p -= x; q += 2*x;
} while (q >= spaces);
system("PAUSE");
return EXIT_SUCCESS;
}
Thanks!