#include
#define N 10
int main(void)
{
int ar[N][N]={0};
int i,j;
int k = 1;
for(i=0;i
ar[i][i]=1;
ar[i][0]=1;
}
for(i=2;i
for(i=0;i
for(j=0;j
printf("%5d",ar[i][j]);
}
printf("\n");
if (k == N)
{
break;
}
k++;
}
return 0;
}
这是我写的希望能帮到你 for(i=1;i for(j=1;j<=i;j++) }
#include
#define LEN 10
int main ()
{
int i = 0 ;
int j = 0 ;
int n=10;
int array[LEN][LEN] = {0};
array[0][0] = 1;
printf("%d\n",array[0][0]);
for ( i = 1 ; i <10;i++)
{
array[i][0] = 1;
printf("%d ",array[i][0]);
for (j = 1 ; j <= i ; j++)
{
array[i][j] = array[i-1][j-1] + array[i-1][j];
printf("%d ",array[i][j]);
}
printf("\n");
}
return 0;
}
下面这个用的是c++
#include
#include
using namespace std;
#define LEN 100
int main ()
{
int i=0;
int j=0;
int p[LEN][LEN]={0};
p[0][0]=1;
int n=10;
p[0][0]=1;
cout<
p[i][0]=1;
cout<
{
p[i][j]=p[i-1][j-1]+p[i-1][j];
cout<
cout<
return 0;
}