fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main(){
  5.  
  6. int n;
  7. cin>>n;
  8.  
  9. if(n<3 || n%2==0){
  10. cout<<"Invalid";
  11. return 0;
  12. }
  13.  
  14. int top_space = (n-3)/2;
  15.  
  16. for(int i=0; i<(n/2)+1; i++){
  17. if(i<top_space) cout<<" ";
  18. else cout<<"e";
  19.  
  20. for(int j=0; j<n+1; j++) cout<<" ";
  21.  
  22. for(int s=0; s<n/2-i; s++) cout<<" ";
  23.  
  24. for(int j=0; j<2*i+1; j++) cout<<"*";
  25.  
  26. cout<<endl;
  27. }
  28.  
  29.  
  30.  
  31.  
  32. for(int i=0; i<n; i++){
  33. for(int j=0; j<n+3; j++){
  34. if(j==0 || j==n+2 || i==n-1) cout<<"e";
  35. else cout<<" ";
  36. }
  37. cout<<endl;
  38. }
  39.  
  40.  
  41.  
  42.  
  43.  
  44. }
Success #stdin #stdout 0s 5312KB
stdin
5
stdout
         *
e       ***
e      *****
e      e
e      e
e      e
e      e
eeeeeeee