5 solutions

  • 6
    @ 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;
    }
    
    
    • 1
      @ 2026-8-21 14:48:28
      #include<bits/stdc++.h>
      using namespace std;
      string x(string s)
      {
      	int n=s.size();
      	for(int i=0;i<n;i++)
      	{
      		if(s[i]>='a'&&s[i]<='z')
      		{
      			s[i]=s[i]+'A'-'a';
      		}
      	}
      	return s;
      }
      int main()
      {
      	string s;
      	cin>>s;
      	string st=x(s);
      	cout<<st;
      	return 0;
      }
      
      • 1
        @ 2026-8-14 14:20:41
        #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(i==(n+1)/2&&j!=(n+1)/2)
        			{
        				cout<<"-";
        			}
        			else if(i!=(n+1)/2&&j==(n+1)/2)
                    {
        				cout<<"|";	
        			}
        			else
        			{
        				cout<<"x";
        			}
        		}
        		cout<<endl;
        	}
        	return 0; 
        }
        
        • 1
          @ 2025-7-11 10:14:21
          #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;
          }
          
          
          
          • -5
            @ 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
            86
            Accepted
            49
            Uploaded By