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 <bits/stdc++.h>
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. cout<<"Enter a Number to Print Pattern:"<<endl;
  15. int n;
  16. cin>>n;
  17. if(n>=3 && (n%2!=0)){
  18. int a=ceil(n/2);
  19.  
  20. for(int i=0;i<n;i++){
  21.  
  22. for(int j=0;j<(3*n+2);j++){
  23. if(i!=a && (j<n || j>=(2*n+2))){
  24. cout<<" "<<" ";
  25. }
  26.  
  27. else if(i==a && (j<n || j>=(2*n+2))){
  28. cout<<"e"<<" ";
  29. }
  30. else if ((j>=n && j<(2*n+2))){
  31. cout<<"*"<<" ";
  32. }
  33.  
  34. }
  35. cout<<endl;
  36. }
  37. }
  38. else{
  39. cout<<"enter a Valid number"<<endl;
  40. }
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
Enter a Number to Print Pattern:
enter a Valid number