四有青年加盟费多少钱?:1.将一个数组中的值按逆序重新存放。例如,原来顺序为8,6,5,4,1。要求改为1,4,5,6,8。

来源:百度文库 编辑:中科新闻网 时间:2024/03/29 15:16:20
2.打印出以下的杨辉三角形(要求打印出10行)。
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
。 。 。 。 。 。
。 。 。 。 。 。
。 。 。 。 。 。

1,
void verse(int n,Datatype a[])
{
int i,m=n/2;
Datatype temp;
for(i=0;i<m;i++)
{
temp=a[m-i-1];
a[m-i-1]=a[i];
a[i]=temp;
}//ok
2
#define N 11
main()
{
int i,j,a[N][N];
for(i=1;i<N;i++)
{
a[i][i]=1;
a[i][1]=1;
}
for(i=3;i<N;i++)
for(j=2;j<=i-1;j++)
a[i][j]=a[i-1][j-1]+a[i-1][j];
for(i=1;i<N;i++)
{
for(j=1;j<=i;j++)
printf("%6d",a[i][j]);
printf("\n");
}

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
。 。 。 。 。 。
。 。 。 。 。 。
。 。 。 。 。 。

x

11

213

1