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