Thursday, 24 November 2016

Hollow Diamond



#include <iostream>
using namespace std;
int main ()
{
    int space,line,rows,start;
    cout <<"Enter number of rows want display  " <<endl;
    cin >>rows;
    for (line=1; line<=rows; line=line+2){
        for (space=1; space<=rows-line; space=space+2){
            cout <<' ';
        }for (start=1; start<=line; start++){
            if (start==1){
                cout <<"*";}
            else if (start==line){
                cout <<"*";
            }else {
                cout <<" ";}
        }
        cout <<endl;

    }
    int row;
    row=rows-2;
    for (line=row; line>=1; line=line-2){
        for (space=1; space<=rows-line; space=space+2){
            cout <<' ';
        }for (start=1; start<=line; start++){
            if (start==1){
                cout <<"*";}
            else if (start==line){
                cout <<"*";
            }else {
                cout <<" ";
        }
        }
        cout <<endl;

        }
   
    return 0;
}

No comments: