#include <stdio.h>
int main()
{
int n = 5,x;
int i,j;
for(i = 1; i <= n; i++)
{
for (j = 1; j <= n; j++)
{
x = 2 * (i + j);
if (i + j <= n + 1)
{
printf("%2d ", x - 3);
}
else
{
printf("%2d ", x - (n * 2 + 3));
}
}
printf("\n");
}
return 0;
}
#include <iostream.h>
int main()
{
int n = 5,x;
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++)
{
x = 2 * (i + j);
if (i + j <= n + 1)
{
cout<<(x - 3)<<" ";
}
else
{
cout<<(x - (n * 2 + 3))<<" ";
}
}
cout<<endl;
}
return 0;
}
class PatternProg
{
public static void main(String args[])
{
int n = 5;
int x;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
x = 2 * (i + j);
if (i + j <= n + 1)
{
System.out.print((x - 3)+" ");
}
else
{
System.out.print((x - (n * 2 + 3))+" ");
}
}
System.out.println();
}
}
}
using System;
class PatternProg
{
public static void Main()
{
int n = 5;
int x;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
x = 2 * (i + j);
if (i + j <= n + 1)
{
Console.Write((x - 3) + " ");
}
else
{
Console.Write((x - (n * 2 + 3)) + " ");
}
}
Console.WriteLine();
}
Console.ReadKey(true);
}
}
n = 5
for x in range(1, n + 1):
for y in range(1, n + 1):
d = 2 * (x + y)
if x + y <= n + 1:
print(d - 3, end=" ");
else:
print(d - (n * 2 + 3), end=" ");
print()