C
#include <stdio.h>
int main()
{
int i,j,p;
int n=5;
for(i=0;i<n;i++)
{
p = 0;
for(j=0;j<n;j++)
{
if(i==j || (i+j == n-1) || ((i==0 || i == n-1) && j == n/2))
{ printf("%c ",p+65);
p++;
}
else
{
printf(" ");//two ws
}
}
printf("\n");
}
return 0;
}
C++
#include <iostream.h>
int main()
{
int n=5;
for(int i=0;i<n;i++)
{
int p = 0;
for(int j=0;j<n;j++)
{
if(i==j || (i+j == n-1) || ((i==0 || i == n-1) && j == n/2))
{
cout<<char(p+65)<<" ";
p++;
}
else
{
cout<<" ";//two ws
}
}
cout<<endl;
}
return 0;
}
Java
class PatternProg
{
public static void main (String args[])
{
int n=5;
for(int i=0;i<n;i++)
{
int p = 0;
for(int j=0;j<n;j++)
{
if(i==j || (i+j == n-1) || ((i==0 || i == n-1) && j == n/2))
{
System.out.printf("%c ",p+65);// space after %c
p++;
}
else
{
System.out.printf(" ");// two ws
}
}
System.out.println();
}
}
}
C#
Python