This is Discussion thread about 卐 Ganesha’s Pattern
Discussion About 卐 Ganesha's Pattern
Working Code For Ganesha’s Pattern using C++ :-
using namespace std;
int main() {
int i,j, r;
cin >> r;
if((r>=5 || r<=99) && r%2 != 0)
{
for(i=1;i<=r/2+1;i++)
{
if(i==r/2+1)
{
for(j=1;j<=r;j++)
cout << "*";
break;
}
for(j=1;j<=r/2+1;j++)
{
if(j==1 || j==r/2+1)
cout << "*";
else cout << " ";
}
while(j<=r)
{
if(i==1)
cout << "*" ;
else cout << " " ;
j++;
}
cout << "\n";
}
cout << "\n";
for(i=r/2+2;i<=r;i++)
{
for(j=1;j<=r/2;j++)
{
if(i==r)
cout << "*";
else cout << " ";
}
while(j<=r)
{
if(j==r || j==r/2+1)
cout << "*";
else cout << " ";
j++;
}
cout << "\n";
}
}
return 0;
}
// By Akshit Bhatt
#include
using namespace std;
int main(){
int i,j,n;
cin>>n;
for(i=1;i<=n;i++){
if(i<=((n/2)+1)){
for(j=1;j<=n;j++){
if(j==1 || j==(n/2+1) ||i==n/2+1 || (i==1 && j>(n/2+1))){
cout<<"";
}
else{
cout<<" “;
}
}
}
else
{
for(j=1;j<=n;j++){
if(j==(n/2+1) || j==n || (i==n && j<(n/2+1))){
cout<<”";
}
else{
cout<<" ";
}
}
}
cout<<endl;
}
return 0;
}