fork download
  1. #include <iostream>
  2. using namespace std;
  3. void printPattern(int n){
  4. for(int i = 1; i <= n -1; i++){
  5. cout<<"*";
  6. for(int j = 1; j <= n+2; j++){
  7. cout<<" ";
  8. };
  9. cout<<"*"<<endl;
  10. };
  11. for(int i =1; i <= n +4; i++){
  12. cout<<"*";
  13. }
  14. cout<<endl;
  15.  
  16. for (int i = 1; i <= n; i += 2) {
  17.  
  18. int spaces = (n + 4 - i) / 2;
  19. for (int j = 0; j < spaces; j++) {
  20. cout << " ";
  21. }
  22.  
  23. for (int k = 1; k <= i; k++) {
  24. cout << "e";
  25. }
  26. cout << endl;
  27. }
  28. };
  29. int main() {
  30. int n;
  31. cout<<"enter the number"<<endl;
  32. cin>>n;
  33. if(n%2==0){
  34. cout<<"even number are not allowed"<<endl;
  35. return 0;
  36. }
  37. if(n < 3 ){
  38. cout<<"number should be greater then and equal to 3";
  39. return 0;
  40. }
  41. // your code goes here
  42. printPattern(n);
  43. return 0;
  44. }
Success #stdin #stdout 0.01s 5284KB
stdin
11
stdout
enter the number
*             *
*             *
*             *
*             *
*             *
*             *
*             *
*             *
*             *
*             *
***************
       e
      eee
     eeeee
    eeeeeee
   eeeeeeeee
  eeeeeeeeeee