diamond shape in c++
please give feedback on :)
#include <iostream>
using namespace std;
#include<Windows.h>
void main()
{
int n;
//system("color f4");
cout<<endl<<endl<<endl<<endl<< " ahoooo khouch tofaani karein "<<endl;
Sleep(400);
cin>>n;
bool bol=false;
int a,b;
a=n;
b=n;
/*for(int i=0;i<n;i++)
{
for(int c=0;c<=(n+n);c++)//loop for upper STAR
{
if(c<=a&&c>=b)
{
cout<<"*";
}
else one method
cout<<" ";
}
cout<<endl;
a++;
b--;
Sleep(100);
}
int d=0,e=2*n;
for(int j=0;j<=n;j++)//loop for lower star
{
for(int f=0;f<=2*n;f++)
{
if(f<=e&&f>=d)
{
cout<<"*";
}
else
cout<<" ";
}
cout<<endl;
Sleep(100);
d++;
e--;
}*/
int c=n,d=c,e=c;
for(int i=0;i<=2*n;i++)
{
for(int j=0;j<=2*n;j++)
{
if(c<=j&&d>=j)
{
cout<<" ";
}
else cout<<"*";
}
cout<<endl;
if(i>=e)
{
c++;d--;
}
else
{
c--;d++;
}
}
}
#include <iostream>
using namespace std;
#include<Windows.h>
void main()
{
int n;
//system("color f4");
cout<<endl<<endl<<endl<<endl<< " ahoooo khouch tofaani karein "<<endl;
Sleep(400);
cin>>n;
bool bol=false;
int a,b;
a=n;
b=n;
/*for(int i=0;i<n;i++)
{
for(int c=0;c<=(n+n);c++)//loop for upper STAR
{
if(c<=a&&c>=b)
{
cout<<"*";
}
else one method
cout<<" ";
}
cout<<endl;
a++;
b--;
Sleep(100);
}
int d=0,e=2*n;
for(int j=0;j<=n;j++)//loop for lower star
{
for(int f=0;f<=2*n;f++)
{
if(f<=e&&f>=d)
{
cout<<"*";
}
else
cout<<" ";
}
cout<<endl;
Sleep(100);
d++;
e--;
}*/
int c=n,d=c,e=c;
for(int i=0;i<=2*n;i++)
{
for(int j=0;j<=2*n;j++)
{
if(c<=j&&d>=j)
{
cout<<" ";
}
else cout<<"*";
}
cout<<endl;
if(i>=e)
{
c++;d--;
}
else
{
c--;d++;
}
}
}
Comments
Post a Comment