2 条题解

  • 1
    @ 2025-7-29 11:46:48
    #include<bits/stdc++.h>
    using namespace std;
    long long n,a[105][105],c=1;
    int main()
    {
    	cin>>n;
    	for(int i=1;i<=n;i++)
    	{
    		int x=i,y=1;
    		while(x>=1)
    		{
    			a[x][y]=c;
    			c++;
    			x--,y++;
    		}
    	}
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=n-i+1;j++) cout<<a[i][j]<<" ";
    		cout<<endl;
    	}	
    	return 0;
    }
    
    • 0
      @ 2024-11-3 15:30:36
      #include <iostream>
      using namespace std;
      int a[105][105],h,k=1,l,hy=0;
      int main(){
          int n;
          cin >> n;
          hy = n-1;
          for(int i = 1;i<=n;i++) {
              h = n-hy;
              l = 1;
              for (; h != 0;) {
                  a[h][l] = k++;
                  h--;
                  l++;
              }
              hy--;
          }
          for (int i = 1; i <= n; i++) {
              for (int j = 1; j <= n; j++) {
                  if (a[i][j] == 0){
                      continue;
                  }else {
                      printf("%d ", a[i][j]);
                  }
              }
              cout << "\n";
          }
      }
      

      (this is 博客on 白的码)

      • 1

      信息

      ID
      298
      时间
      1000ms
      内存
      64MiB
      难度
      10
      标签
      递交数
      8
      已通过
      4
      上传者