2 solutions
-
1
#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
Information
- ID
- 2591
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- (None)
- # Submissions
- 19
- Accepted
- 8
- Uploaded By