2 solutions

  • 0
    @ 2026-2-22 16:05:01
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a;
        cin>>a;
        for(int i=0;i<a;i++)
        {
            if(i==a/2)
            {
                cout<<"|";
                for(int j=0;j<a-2;j++)
                {
                    cout<<"-";
                }
                cout<<"|";
            }
            else
            {
                cout<<"|";
                for(int j=0;j<a-2;j++)
                {
                    cout<<"a";
                }
                cout<<"|";
            }
            cout<<"\n";
        }
    }
    
    • -1
      @ 2025-11-27 11:55:05

      C++ :

      #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((j!=1 && j!=N) && i==(N+1)/2) cout<<'-';
      			else cout<<'a';
      		}
      		cout<<endl;
      	}
      	return 0;
      }
      
      • 1

      Information

      ID
      39
      Time
      1000ms
      Memory
      128MiB
      Difficulty
      6
      Tags
      # Submissions
      15
      Accepted
      11
      Uploaded By