#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int N;
cout << "Enter any number for the size of the Z-Shape: ";
cin >> N;
while( N<=3 )
{
cout << "Invalid Input! Enter again: ";
cin >> N;
}
int i,
space=N;
cout << "The Z-Shape pattern (with spaces) is:\n";
for( i=1 ; i<=N/2+1 ; i++)
cout << "* ";
for( i=1 ; i<=N-1 ; i++)
{
space-=1;
cout << endl
<< setw(space)
<< "*";
}
for( i=1 ; i<=N/2 ; i++)
cout << " *";
cout << endl;
return 0;
}
No comments:
Post a Comment