2 solutions

  • 0
    @ 2026-11-7 12:36:38
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a;
        cin>>a;
        int s=1;
        for(int i=1;i<=a;i++)
        {
            for(int j=1;j<=a;j++)
            {
                if(i+j==a+1||i==j)
                {
                    cout<<"+";
                }
                else
                {
                    cout<<"-";
                }
            }
            cout<<endl;
        }
        return 0;  
    }
    • 0
      @ 2026-10-24 19:42:42
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n;
          cin>>n;
          int h=n/2+1;
          int x=1,y=h;
          for(int i=1;i<=h;i++)
          {
              for(int j=1;j<=n;j++)
              {
                  if(abs(x-i)+abs(y-j)==h-1)
                  {
                      cout<<"+";
                  }
                  else
                  {
                      cout<<"-";
                  }
              }
              cout<<endl;
          }
          x=n;
          for(int i=h+1;i<=n;i++)
          {
              for(int j=1;j<=n;j++)
              {
                  if(abs(x-i)+abs(y-j)==h-1)
                  {
                      cout<<"+";
                  }
                  else
                  {
                      cout<<"-";
                  }
              }
              cout<<endl;
          }
      	return 0;
      }
      
      • 1

      Information

      ID
      1177
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      5
      Tags
      (None)
      # Submissions
      84
      Accepted
      34
      Uploaded By