2 solutions

  • 1
    @ 2025-5-24 15:33:23
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n;
    	cin>>n;
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=1;j<=n;j++)
    		{
    		
    			if(j==1||j==n) //边缘竖线的判断 
    			{
    				cout<<"|";
    			}
    			else if(i==1||i==n) //边缘横线的判断 
    			{
    				cout<<"-";
    			}
    			else if(j==(n+1)/2&&i!=(n+1)/2)//中间竖线的判断 
    			{
    				cout<<"|";
    			}
    			else if(i==(n+1)/2&&j!=(n+1)/2) //中间横线的判断 
    			{
    				cout<<"-";
    			}
    			else 
    			{
    				cout<<"x";
    			}
    		}
    		cout<<endl;
    	}
    	return 0;
    }
    
    
    • 0
      @ 2025-6-7 10:22:14

      #include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; for(int i=1;i<=n;i++) { for(int j=1;j<=n-i;j++) { cout<<" "; } char ch='A'+i-1; for(char c=ch;c>='A';c--) { cout<<c; } for(char c='B';c<=ch;c++) { cout<<c; } cout<<endl; } return 0; }

      • 1

      Information

      ID
      2591
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      3
      Tags
      (None)
      # Submissions
      19
      Accepted
      8
      Uploaded By