Write a function to construct the image shown below.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
#include <stdio.h>
#include <conio.h>
void main ( )
{
static int pas[5][5];
int i, j, k;
clrscr ( );
pas[0][0] = 1;
printf("\n\n\n");
for ( i = 0; i < 5; i++ )
{
printf("\t\t\t");
for ( k = 5; k >= i; k-- )
printf (" ");
for ( j = 0; j <= i; j++ )
{
if ( i || j )
{
pas[i][j]=pas[i-1][j-1]+pas[i-1][j];
}
printf("%d ",pas[i][j]);
}
printf("\n\n");
}
getch();
}
Click here to contact us
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
#include <stdio.h>
#include <conio.h>
void main ( )
{
static int pas[5][5];
int i, j, k;
clrscr ( );
pas[0][0] = 1;
printf("\n\n\n");
for ( i = 0; i < 5; i++ )
{
printf("\t\t\t");
for ( k = 5; k >= i; k-- )
printf (" ");
for ( j = 0; j <= i; j++ )
{
if ( i || j )
{
pas[i][j]=pas[i-1][j-1]+pas[i-1][j];
}
printf("%d ",pas[i][j]);
}
printf("\n\n");
}
getch();
}
Click here to contact us
No comments:
Post a Comment