1 solutions

  • 0
    @ 2022-3-21 19:13:56
    #include<iostream>
    using namespace std;
    int main(){
    	int n,used=1,i=0,sum=0,ans=0;
    	char a;
    	cin>>n>>a;
    	for(i=3;used+i*2<=n;i+=2){
    		used+=i*2;
    		sum++;
    	}
    	ans=n-used;
    	for(int j=0;j<sum+1;j++){
    		for(int l=0;l<i-2;l++){
    			if(l>=j&&l<=i-3-j)cout<<a;
    			else cout<<" ";
    		}
    		cout<<endl;
    	}
    	for(int j=sum-1;j>=0;j--){
    		for(int l=0;l<i-2;l++){
    			if(l>=j&&l<=i-3-j)cout<<a;
    			else cout<<" ";
    		}
    		cout<<endl;
    	}
    	cout<<ans;
    	return 0;
    }
    
    • 1

    Information

    ID
    208
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    4
    Tags
    # Submissions
    54
    Accepted
    25
    Uploaded By