fork download
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
  5. C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
  6. Code, Compile, Run and Debug online from anywhere in world.
  7.  
  8. *******************************************************************************/
  9. #include <iostream>
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14.  
  15. int n = 5;
  16.  
  17. if(n%2 == 0 || n <= 0 || n == 1) {
  18. cout<<"don't run with even, negative, zero and one"<<endl;
  19. return 0;}
  20.  
  21. for(int row = 0; row<n+2; row++){
  22.  
  23. if(row != n+1){
  24. for(int col = 0; col<n-1; col++){
  25. std::cout<<" ";
  26.  
  27. }
  28. std::cout <<"e ";
  29. }
  30.  
  31.  
  32. if(row == 0){
  33. for(int col = 0; col<n+2; col++){
  34. std::cout<<"* ";
  35. }
  36. }
  37.  
  38. if(row == (n+2)/2){
  39. for(int col = 0; col<n; col++){
  40. std::cout<<"* ";
  41. }
  42.  
  43. }
  44.  
  45. if(row == n+1){
  46. for(int col = 0; col<n-1; col++){
  47. std::cout<<"* ";
  48. if(col == n-2){
  49. std::cout <<"e ";
  50. }
  51. }
  52. }
  53.  
  54. std::cout<< std::endl;
  55.  
  56. }
  57.  
  58. return 0;
  59. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
        e * * * * * * * 
        e 
        e 
        e * * * * * 
        e 
        e 
* * * * e