2 条题解

  • 1
    @ 2023-3-19 10:25:38

    #include<bits/stdc++.h> using namespace std; int main() { int n,i,j,s; cin>>n; int a[2n+1][2n+1]; for(i=0;i<n+1;i++) { s=n; for(j=0;j<n+1;j++) { a[i][j]=s; if(j<i) s--; } for(j=n+1;j<2n+1;j++) { if(j>2n-i) s++; a[i][j]=s; } } for(i=n+1;i<2n+1;i++) { s=n; for(j=0;j<n+1;j++) { a[i][j]=s; if(j<2n-i) s--; } for(j=n+1;j<2n+1;j++) { if(j>i) s++; a[i][j]=s; } } for(i=0;i<2n+1;i++) { for(j=0;j<2*n+1;j++) printf("%2d",a[i][j]); cout<<endl; } }

    • -1
      @ 2023-3-11 8:41:52
      #include<iostream>
      using namespace std;
      int main(){
      	int n,i,j,s;
      	cin>>n;
      	int a[2*n+1][2*n+1];
      	for(i=0;i<n+1;i++){
      		s=n;
      		for(j=0;j<n+1;j++){
      			a[i][j]=s;
      			if(j<i) s--;
      		}
      		for(j=n+1;j<2*n+1;j++){
      			if(j>2*n-i) s++;
      			a[i][j]=s;
      		}
      	}
      	for(i=n+1;i<2*n+1;i++){
      		s=n;
      		for(j=0;j<n+1;j++){
      			a[i][j]=s;
      			if(j<2*n-i) s--;
      		}
      		for(j=n+1;j<2*n+1;j++){
      			if(j>i) s++;
      			a[i][j]=s;
      		}
      	}
      	for(i=0;i<2*n+1;i++){
      		for(j=0;j<2*n+1;j++) printf("%2d",a[i][j]);
      		cout<<endl;
      	}
      }
      
      • @ 2023-9-19 21:27:51

        楼上那位差个include<stdio.h>

        #include<iostream>
        #include<stdio.h>
        using namespace std;
        int main(){
        	int n,i,j,s;
        	cin>>n;
        	int a[2*n+1][2*n+1];
        	for(i=0;i<n+1;i++){
        		s=n;
        		for(j=0;j<n+1;j++){
        			a[i][j]=s;
        			if(j<i) s--;
        		}
        		for(j=n+1;j<2*n+1;j++){
        			if(j>2*n-i) s++;
        			a[i][j]=s;
        		}
        	}
        	for(i=n+1;i<2*n+1;i++){
        		s=n;
        		for(j=0;j<n+1;j++){
        			a[i][j]=s;
        			if(j<2*n-i) s--;
        		}
        		for(j=n+1;j<2*n+1;j++){
        			if(j>i) s++;
        			a[i][j]=s;
        		}
        	}
        	for(i=0;i<2*n+1;i++){
        		for(j=0;j<2*n+1;j++) printf("%2d",a[i][j]);
        		cout<<endl;
        	}
        }
        
    • 1

    信息

    ID
    209
    时间
    1000ms
    内存
    16MiB
    难度
    8
    标签
    递交数
    102
    已通过
    19
    上传者