Thursday, January 22, 2015
c++ Creating Diamond Shape
#include "stdafx.h"
#include<iostream>
using namespace std;
int main() {
int a, b, c;
int n = 0;
cout<<"Enter N:";
cin>>n;
for (a = 1; a <= n; a++)
{
for (b = 0; b < (n - a); b++)
cout<<" ";
for (b = 1; b <= a; b++)
cout<<"*";
for (c = 1; c < a; c++)
cout<<"*";
cout<<"\n";
}
for (a = n - 1; a >= 1; a--)
{
for (b = 0; b < (n - a); b++)
cout<<" ";
for (b = 1; b <= a; b++)
cout<<"*";
for (c = 1; c < a; c++)
cout<<"*";
cout<<"\n";
}
cout<<"\n";
cin.get();
cin.get();
return 0;
}
Labels:
cplusplus Tutorials
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment