Please help me!

i've been doing this code since yesterday.

#include <iostream>
using namespace std;
int main()
{
int X=1;
do{
int Y=0;
do{
cout<<" ";
Y++;}
while(Y<=5-X||Y<=X-5);

int Z=1;
do{
cout<<"*";
Z++;}
while(Z<=X&&Z<=10-X);

cout<<endl;
X++;}
while(X<=9);

}


THE OUTPUT IS A HALF DIAMOND, BUT IM HAVING DIFFICULTY REMOVING THE SPACE IN THE EDGE, IT SHOULDN'T HAVE A SPACE. THANKS
Last edited on
Line 9: if( Y != 0 ) cout<<" ";
but we are not allowed to use other than do while
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>

int main()
{
    char line[] = "    *\n" ;
    int line_number = 0 ;

    do
    {
        std::cout << line ;
        ++line_number ;
        line[4-line_number] = '*' ;
    }
    while( line_number < 5 ) ;

    do
    {   line[line_number-5] = ' ' ;
        std::cout << line ;
        ++line_number ;
    }
    while( line_number < 10 ) ;
}

http://coliru.stacked-crooked.com/a/f1c92ef4fea9aeb5
Topic archived. No new replies allowed.