1 条题解

  • 0
    @ 2021-6-15 10:13:27

    C++ :

    #include<iostream>
    #include<cstdlib>
    using namespace std;
    int main()
    {
    	int n;
    	int a[21][21];
    	cin>>n;
    	int g;
    	for(int i=1;i<=n;i++)
    	{
    		g=0;
    	    for(int j=i;j<=n;j++)
    		{
    			cout<<j<<' ';
    			g++;
    			if(j==n&&g!=n)
    				for(int w=j-1;g!=n;w--)
    				{
    			        cout<<w<<' ';
    			        g++;
    				}
    		}
            if(g==n)
    			cout<<endl;
    	}
    	//system("pause");
    }
    
    

    Pascal :

    const n=10;
    var
    
      b:array[1..n,1..n] of integer;
      i,j:integer;
    
    begin
    
      for i:=1 to n do
       for j:=1 to n do
         b[i,j]:=0;
    
        for i:=1 to n do
        for j:=1 to n-i+1 do
          b[i,j]:=i+j-1;
    
    
      for i:=2 to n do
          for j:=n downto n-i+2 do
            b[i,j]:=2*n+1-i-j;
    
    
      for i:=1 to n do
      begin
    
        for j:=1 to n do
          write(b[i,j],' ');
        writeln;
       end;
    
    end.
    
    • 1

    信息

    ID
    459
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者