fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int n;
  7. cin>>n;
  8. if(n>=3 && n%2!=0){
  9. for(int i=0;i<n;i++){
  10. int stars ;
  11. if(i<=(n/2)){
  12. stars=i+1;
  13. }
  14. else{
  15. stars=n-i;
  16. }
  17.  
  18. for(int j=0;j<n-stars;j++){
  19. cout<<" ";
  20. }
  21. for(int k=0;k<stars;k++){
  22. cout<<"*";
  23. }
  24. if(i==n/2){
  25. for(int l=0;l<=n+2;l++){
  26. if(l==n+2){
  27. cout<<"*";
  28. }
  29. else{
  30. cout<<"e";
  31. }
  32. }
  33. }
  34. else{
  35. for(int l=0;l<=n+2;l++){
  36. if(l==n+2){
  37. cout<<"*";
  38. }
  39. else{
  40. cout<<" ";
  41. }
  42. }
  43. }
  44. cout<<endl;
  45. }
  46. }else{
  47. cout<<"Enter Valid Input 'Enter Odd numbers with greater than equal to 3'";
  48. }
  49.  
  50. return 0;
  51. }
Success #stdin #stdout 0.01s 5308KB
stdin
-4
stdout
Enter Valid Input 'Enter Odd numbers with greater than equal to 3'