#include <stdio.h>
int main()
{
int n, temp = 0;
printf("Enter the range\n");
scanf("%d", &n);
for (int i = n; i > 0; i--)
{
for (int k = n; k > (i - 1); k--)
{
printf("%d ", k);
}
for (int j = 0; j < (2 * i) - 2; j++)
{
printf("%d ", i);
}
for (int l = i + 1; l <= n; l++)
{
printf("%d ", l);
}
printf("\n");
}
for (int i = 1; i < n; i++)
{
for (int j = n; j > i; j--)
{
printf("%d ", j);
}
for (int o = 1; o < i + 1; o++)
{
printf("%d ", i + 1);
}
for (int p = 2; p < i + 1; p++)
{
printf("%d ", i + 1);
}
for (int j = i + 1; j <= n; j++)
{
printf("%d ", j);
}
printf("\n");
}
return 0;
}
output:
Comments
Post a Comment