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