3 solutions

  • 1
    @ 2026-6-20 15:36:19
    #include <bits/stdc++.h>
    using namespace std;
    int main(){//此
        int n;
        cin>>n;
        int m=(n+1)/2;//为
        for(int i=1;i<=n;i++){
            if(i==1||i==n||i==m){
                cout<<'|';//水
                for(int j=2;j<n;j++) 
    				cout<<'-';
                cout<<'|';
            }else{
                cout<<'|';//印
                for(int j=2;j<n;j++) 
    				cout<<'x';
                cout<<'|';
            }
            cout<<endl;
        }
        return 0;
    }
    
    • 0
      @ 2026-2-22 16:29:03
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n;
          cin>>n;
          for(int i=0;i<n;i++)
          {
              cout<<"|";
              for(int j=0;j<n-2;j++)
              {
                  if(i==0||i==n-1||i==n/2)
                  {
                      cout<<"-";
                  }
                  else
                  {
                      cout<<"x";
                  }
              }
              cout<<"|\n";
          }
      }
      
      • -2
        @ 2025-11-27 11:55:05

        C++ :

        #include <iostream>
        using namespace std;
        int main() {
        int n;
        cin >> n;
        for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
        char ch;
        if (j == 0 || j == n - 1) {
        ch = '|';
        } else if (i == 0 || i == n - 1 || i == n / 2) {
        ch = '-';
        } else {
        ch = 'x';
        }
        cout << ch;
        }
        cout << endl;
        }
        return 0;
        }
        
        • 1

        Information

        ID
        37
        Time
        1000ms
        Memory
        512MiB
        Difficulty
        5
        Tags
        # Submissions
        43
        Accepted
        16
        Uploaded By