Pattern 134

Pattern 134 post thumbnail image

C

#include <stdio.h>
#include <conio.h>
int main()
{
  int i,j,k;

  for(i=5; i>=1; i--)
  {
    for(k=4; k>=i; k--)
    {
      printf(" ");
    }
    for(j=i; j>=1; j--)
    {
      printf("%d ",i);
    }
    printf("\n");
  }
  return 0;
}

C++

 #include <iostream.h>
 
 int main()
 {
 int i,j,k;
 
 int p_height=5;
 
 
 for(int i =p_height; i>=1; i--)
 {
  for(int k =p_height-1; k>=i; k--)
  {
  cout<<" ";
  }
  for(int j =i; j>=1; j--)
  {
  cout<<i<<" ";
  }
 cout<<endl;
 }
  return 0;
 } 

Java

   class PatternProg
   {
     public static void main(String a[])
     {
     int p_height = 5;
 
     for (int i = p_height; i >= 1; i--)
     {
      for (int k = p_height - 1; k >= i; k--)
      {
      System.out.print(" ");
      }
      for (int j = i; j >= 1; j--)
      {
      System.out.print(i+" ");
      }
     System.out.print("\n");
     }
      
     }
 }

C#

using System;

class PatternProg
{
  public static void Main(string[] a)
  {
    int p_height = 5;

    for (int i = p_height; i >= 1; i--)
    {
      for (int k = p_height - 1; k >= i; k--)
      {
        Console.Write(" ");
      }
      for (int j = i; j >= 1; j--)
      {
        Console.Write(i + " ");
      }
      Console.WriteLine();
    }
    Console.ReadKey(true);
  }
}

Python

for x in range(5, 0, -1):
    for y in range(x, 5):
        print(" ", end="")
    for z in range(0, x):
        print(str(x) + " ", end="")
    print()

Tutorial (YouTube)

0 0 votes
Rate this Program
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Related Patterns