patternprogram_439 softethics

Pattern 439

C

#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;
}

C++

Java

C#

Python

0 0 votes
Rate this Program
Subscribe
Notify of
guest


0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments