#include <stdio.h>
int main()
{
int n = 4;
int size = (n * (n + 1) / 2);
int x = 1,t;
int i,j;
for(i = 1; i <= n; i++)
{
t = size - (n - i);
for(j = 1; j <= 2 * n; j++)
{
if (j > 2 * (i - 1))
{
if (j <= (2 * n) / 2 + i - 1)
{
printf("%02d ", x);
x++;
}
else
{
printf("%02d ", t);
t++;
}
}
else
{
printf("_ ");
}
}
printf("\n");
size = size - (n - i + 1);
}
return 0;
}
#include <iostream.h>
#include <iomanip.h>
int main()
{
int n = 4;
int size = (n * (n + 1) / 2);
int x = 1,t;
for(int i = 1; i <= n; i++)
{
t = size - (n - i);
for(int j = 1; j <= 2 * n; j++)
{
if (j > 2 * (i - 1))
{
if (j <= (2 * n) / 2 + i - 1)
{
cout<<setw(3)<<x;
x++;
}
else
{
cout<<setw(3)<<t;
t++;
}
}
else
{
cout<<setw(3)<<"_";
}
}
cout<<endl;
size = size - (n - i + 1);
}
return 0;
}
class PatternProg
{
public static void main(String args[])
{
int n = 4;
int size = (n * (n + 1) / 2);
int x = 1;
int t;
for (int i = 1; i <= n; i++)
{
t = size - (n - i);
for (int j = 1; j <= 2 * n; j++)
{
if (j > 2 * (i - 1))
{
if (j <= (2 * n) / 2 + i - 1)
{
System.out.printf("%3d", x);
x++;
}
else
{
System.out.printf("%3d", t);
t++;
}
}
else
{
System.out.printf("%3c", '_');
}
}
System.out.println();
size = size - (n - i + 1);
}
}
}
using System;
class PatternProg
{
public static void Main()
{
int n = 4;
int size = (n * (n + 1) / 2);
int x = 1;
int t;
for (int i = 1; i <= n; i++)
{
t = size - (n - i);
for (int j = 1; j <= 2 * n; j++)
{
if (j > 2 * (i - 1))
{
if (j <= (2 * n) / 2 + i - 1)
{
Console.Write("{0,3:D}", x);
x++;
}
else
{
Console.Write("{0,3:D}", t);
t++;
}
}
else
{
Console.Write("{0,3}", '_');
}
}
Console.WriteLine();
size = size - (n - i + 1);
}
Console.ReadKey(true);
}
}
n = 4
total = (n * (n + 1) // 2)
px = 1
for x in range(1, n + 1):
py = total - (n - x)
for y in range(1, n * 2 + 1):
if y > 2 * (x - 1):
if y <= (n * 2) // 2 + x - 1:
print("{:3d}".format(px), end="")
px += 1
else:
print("{:3d}".format(py), end="")
py += 1
else:
print("{:3s}".format("_"), end="")
print()
total = total - (n - x + 1)