fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n,j,i;
  7. cin>>n;
  8. for(i=1;i<=n;i++){
  9. for(j=1;j<=n;j++){
  10. if(j==1||j==n) cout<<"|";
  11. else if(i==1||i==n||i==(n+1)/2) cout<<"-";
  12. else cout<<"x";
  13. }
  14. cout<<"\n";
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0.01s 5268KB
stdin
7
stdout
|-----|
|xxxxx|
|xxxxx|
|-----|
|xxxxx|
|xxxxx|
|-----|