#include <iostream>
using namespace std;
#define n 13
int M[20][20];int x,y,d;
int mat[20][20],i,j,c=0;
void pascal6(){
cout<<"TRIANGULO DE PASCAL #6.......N="<<n;d=n;
for(x=1;x<=d;x++) for(y=1;y<=d;y++) M[x][y]=0;
for(x=1;x<=d;x++) M[d][x]=M[x][x]=1;
for (y=d-2;y>=1;y--)for (x=d-1;x>=y+1;x--) M[x][y]=M[x+1][y+1]+M[x][y+1];
for(x=1;x<=d;x++){cout<<"\n";for(y=1;y<=d;y++) {if(M[x][y]==0) cout<<" ";
else
cout<<M[x][y]<<"\t";}}
}
void pascal5(){
cout<<"\nTRIANGULO DE PASCAL # 5........N="<<n;
for(x=1;x<=n;x++) for (y=1;y<=n;y++) mat[x][y]=0;
for (x=1;x<=n;x++)mat[1][x]=mat[x][n+1-x]=1;
for (y=n-2;y>=1;y--)for (x=2;x<=n-y;x++)
mat[x][y]=mat[x-1][y+1]+mat[x][y+1];
cout<<"\n\n";
for(i=1;i<=n;i++){for(j=1;j<=n;j++){if (mat[j][i]==0)j=n;
printf("%d\t",mat[j][i]);}
printf("\n");
}
}
int main(){{pascal5();} {pascal6();}
}
No hay comentarios:
Publicar un comentario