3 条题解

  • 2
    @ 2025-4-18 18:20:44
    #include <stdio.h>
    int n, a[11][11], ai, t;
    int main(){
    	scanf("%d", &n);
    	for(int i = 1; i <= n; i ++){
    		t = 0;
    		ai = i - 1;
    		for(int j = 1; j <= n; j ++){
    			if(ai < n && !t)
    				printf("%d ", ++ ai);
    			else
    				printf("%d ", -- ai), t = 1; 
    		}
    		putchar('\n');
    	}
    	return 0;
    }
    
    • 1
      @ 2025-5-6 22:03:48

      这年头谁还用数组呀

      #include<bits/stdc++.h>
      using namespace std;
      const int N=1e5+5,INF=0x3f3f3f3f;
      typedef long long LL;
      int n,sum=1; 
      int main(){
      	cin>>n;
      	for(int i=1;i<=n;i++){
      		for(int i=sum;i<=n;i++)cout<<i<<" ";
      		for(int i=1;i<=sum-1;i++)cout<<n-i<<" ";
      		cout<<endl;
      		sum++;
      	}
      	return 0;
      }
      
      • -6
        @ 2023-4-9 22:41:39

        这题不用2维都可以的

        #include<bits/stdc++.h>
        using namespace std;
        int n,x=1,s; 
        int a[100005];
        int main(){
            int n;
            cin>>n;
            s=n;
            for(int i=1;i<=n;i++){
            	a[i]=i;
        	}
        	for(int i=1;i<=n;i++){
        		for(int j=x;j<=s;j++){
        			cout<<a[j]<<" ";
        		}
        		a[s+1]=a[s]-1;
        		s++;
        		x++;
        		cout<<endl;
        	}
        }
        
        • @ 2025-4-18 18:18:09

          666

        • @ 2025-5-6 22:04:39

          一维都不用 直接舍弃数组 看我题解

      • 1

      信息

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