Program to print Heart pattern-
Have you tried generating different patterns in C or C++ ?
I know its easy but I am sharing what I tried.
Here is simple Heart pattern.
And will look something like this :
//Program to print heart pattern
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
int n,i,j;
cout<<"Enter limit for pattern : ";
cin>>n;
if(n%2==0)
n++;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i==0&&(j>=n/5&&j<=n/2-n/5)||i==0&&(j>=n/2+n/5&&j<=(n-1)-n/5))
cout<<"* ";
else if(i>0&&i<=n/5&&(j==n/5-i||j==n/2+n/5-i||j==n/2-n/5+i||j==(n-1)-n/5+i))
cout<<"* ";
else if((i>n/5&&i<=n/2)&&(j==0||j==n-1))
cout<<"* ";
else if(i>n/2&&(j==i-n/2||j==(n-1)-(i-n/2)))
cout<<"* ";
else
cout<<" ";
}
cout<<"\n";
}
getch();
}
Have you tried generating different patterns in C or C++ ?
I know its easy but I am sharing what I tried.
Here is simple Heart pattern.
And will look something like this :
//Program to print heart pattern
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
void main()
{
clrscr();
int n,i,j;
cout<<"Enter limit for pattern : ";
cin>>n;
if(n%2==0)
n++;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
if(i==0&&(j>=n/5&&j<=n/2-n/5)||i==0&&(j>=n/2+n/5&&j<=(n-1)-n/5))
cout<<"* ";
else if(i>0&&i<=n/5&&(j==n/5-i||j==n/2+n/5-i||j==n/2-n/5+i||j==(n-1)-n/5+i))
cout<<"* ";
else if((i>n/5&&i<=n/2)&&(j==0||j==n-1))
cout<<"* ";
else if(i>n/2&&(j==i-n/2||j==(n-1)-(i-n/2)))
cout<<"* ";
else
cout<<" ";
}
cout<<"\n";
}
getch();
}