1 条题解

  • 0
    @ 2021-6-15 12:50:55

    C :

    #include<stdio.h>
    #include<math.h>
    int main()
    {
    	int n,j,i,a[100][100];
    	while(~scanf("%d",&n))
    	{
    		for(i=0;i<n;i++)
    		{
    			for(j=0;j<i+1;j++)
    			{
    				if(j!=0&&j!=i)
    				{
    				 a[i][j]=a[i-1][j]+a[i-1][j-1];
    				}
    				else a[i][j]=1;
    				printf("%d ",a[i][j]);
    			}
    			printf("\n");
    		}
    	}
    	return 0;
    }
    

    Pascal :

    var  a:array[1..20,1..20] of integer;
         n,i,j:integer;
     begin
       //assign(output,'data1.out');
       //rewrite(output);
       readln(n);
       for i:=1 to n do a[i,1]:=1;
       for i:=1 to n do a[i,i]:=1;
    
       for i:=3 to n do
         for j:= 2 to  i-1 do
           a[i,j]:=a[i-1,j]+a[i-1,j-1];
    
       for i:=1 to n do
        begin
         for j:=1 to i do
           write(a[i,j],' ');
           writeln;
         end;
         //close(output);
     end.
    
    • 1

    信息

    ID
    460
    时间
    1000ms
    内存
    128MiB
    难度
    10
    标签
    递交数
    2
    已通过
    2
    上传者