Pattern 236

Pattern 236 post thumbnail image

C

#include<stdio.h>
int main()
{
  int i,j;
  for (i='E'; i>='A'; i--)
  {
    for (j='A'; j<='E'; j++)
    {
      if (j<i)
        printf("%c",j);
      else
        printf("%c",i);
    }
    printf("\n");
  }
  return 0;
}

C++

#include<iostream.h>
int main()
{
    ch i,j;
    for (i='E'; i>='A'; i--)
    {
        for (j='A'; j<='E'; j++)
        {
            if (j<i)
                cout<<j;
            else
                cout<<i;
        }
        cout<<endl;
    }
    return 0;
}

Java

  class PatternProg
  {
    public static void main(String args[])
    {
        for (char i = 'E'; i >= 'A'; i--)
        {
            for (char j = 'A'; j <= 'E'; j++)
            {
                if (j < i)
                {
                    System.out.print(j);
                }
                else
                {
                    System.out.print(i);
                }
            }
            System.out.println();
        }
    }
}

C#

using System;

class PatternProg
{
  public static void Main()
  {
    for (char i = 'E'; i >= 'A'; i--)
    {
      for (char j = 'A'; j <= 'E'; j++)
      {
        if (j < i)
        {
          Console.Write(j);
        }
        else
        {
          Console.Write(i);
        }
      }
      Console.WriteLine();
    }
    Console.ReadKey(true);
  }
}

Python

for x in 'EDCBA':
 for y in 'ABCDE':
   if y < x:
      print(y, end="")
   else:
      print(x, end="")
 print()

"""
Another way

for x in range(69, 64, -1):
    for y in range(65, 70):
      if y < x:
       print(chr(y), end="")
      else:
       print(chr(x), end="")
    print()
"""
0 0 votes
Rate this Program
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Related Patterns