#include<stdio.h>
int main()
{
int a[66][66];
int n,i,j;
printf("输入n\n");
scanf("%d",&n);
for(i=0;i<n;i++)
a[i][0]=1;
for(i=1;i<n;i++)
{
a[i][i]=1;
for(j=0;j<i;j++)
a[i+1][j+1]=a[i][j]+a[i][j+1];
}
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
printf("%3d",a[i][j]);
printf("\n");
}
return 0;
}
这个输出是左对齐,要输出类似:
uuuuuuuuuuuuuuuuu1
uuuuuuuuuuuuuu1uu1
uuuuuuuuuuu1uu2uu1
uuuuuuuu1uu3uu3uu1
uuuuu1uu4uu6uu4uu1
uu1uu5u10u10uu5uu1
....................................
u是空
int main()
{
int a[66][66];
int n,i,j;
printf("输入n\n");
scanf("%d",&n);
for(i=0;i<n;i++)
a[i][0]=1;
for(i=1;i<n;i++)
{
a[i][i]=1;
for(j=0;j<i;j++)
a[i+1][j+1]=a[i][j]+a[i][j+1];
}
for(i=0;i<n;i++)
{
for(j=0;j<=i;j++)
printf("%3d",a[i][j]);
printf("\n");
}
return 0;
}
这个输出是左对齐,要输出类似:
uuuuuuuuuuuuuuuuu1
uuuuuuuuuuuuuu1uu1
uuuuuuuuuuu1uu2uu1
uuuuuuuu1uu3uu3uu1
uuuuu1uu4uu6uu4uu1
uu1uu5u10u10uu5uu1
....................................
u是空