1 条题解

  • 0
    @ 2025-9-10 0:05:02

    C++ :

    #include<cstdio>
    int main()
    {
    	int n,p=0,t;
    	scanf("%d",&n);
    	printf("%d\n",n);
    	for(int i=1;i<=n;i++)
    	{
    		p++;
    		t=p;
    		if(i%2==1)
    		{
    			for(int j=1;j<=n;j++)
    				if(t>0) 
    				{
    					t--;
    					printf("0");
    				} 
    				else 
    				{
    					printf("1");
    				}
    		}
    		else 
    		{
    			for(int j=1;j<=n;j++)
    				if(t>0) 
    				{
    					t--;
    					printf("1");
    				} 
    				else 
    				{
    					printf("0");
    				}
    		}
    		printf("\n");
    	}
    }
    

    Pascal :

    var n,i,j:longint;
        a:array[1..500] of longint;
    
    begin
     read(n);
    
     writeln(n);
     for i:=1 to n do begin
      for j:=1 to n do if i<>j then
       if a[j]=0 then a[j]:=1 else a[j]:=0;
      for j:=1 to n do write(a[j]);
      writeln;
     end;
    
    end.
    
    • 1

    信息

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