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. int main()
  12. {
  13.  
  14. int n;
  15. cin >> n;
  16. if(n<=1 && n%2 == 0){
  17. std::cout << "Range is invalid" << std::endl;
  18. }
  19. else if(n%2 !=0){
  20. int k=0;
  21. while(k<n*2){
  22. std::cout << " ";
  23. k++;
  24. }
  25. cout<<"e ";
  26. int j=0;
  27. while(j<n+2){
  28. std::cout << "* ";
  29. j++;
  30. }
  31.  
  32. cout<<endl;
  33. int l=0;
  34. while(l<(n-1)/2){
  35. k=0;
  36. while(k<n*2){
  37. std::cout << " ";
  38. k++;
  39. }
  40. std::cout << "e"<< std::endl;
  41. l++;
  42. }
  43. k=0;
  44. while(k<n*2){
  45. std::cout << " ";
  46. k++;
  47. }
  48. cout<<"e ";
  49. j=0;
  50.  
  51. while(j<n){
  52. std::cout << "* ";
  53. j++;
  54. }
  55. cout<<endl;
  56. l=0;
  57. while(l<(n-1)/2){
  58. k=0;
  59. while(k<n*2){
  60. std::cout << " ";
  61. k++;
  62. }
  63. std::cout << "e"<< std::endl;
  64. l++;
  65. }
  66. k=0;
  67. std::cout << " ";
  68. std::cout << " ";
  69. while(k<n-1){
  70. std::cout << "* ";
  71. k++;
  72. }
  73.  
  74. std::cout << "e"<< std::endl;
  75.  
  76. }
  77. else{
  78. cout<<"range is invalid"<<endl;
  79. }
  80. return 0;
  81. }
Success #stdin #stdout 0.01s 5284KB
stdin
5
stdout
          e * * * * * * * 
          e
          e
          e * * * * * 
          e
          e
  * * * * e