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. void pattern1(int n){
  13. for (int i = 0; i<n;i++){
  14. cout<<"*";
  15. }
  16. cout<<endl;
  17. }
  18.  
  19. void pattern2(int n){
  20. int k = 0;
  21.  
  22. for (int i = 0; i<n+2;i++){
  23. cout<<" ";
  24. for(int j = 1; j<n-k-3;j++){
  25. cout<<" ";
  26.  
  27. }
  28.  
  29. cout<<"e"<<endl;
  30.  
  31. }
  32. }
  33.  
  34. void pattern3(int n){
  35. for(int i =0; i< n; i++){
  36. for(int j = 0; j<i; j++){
  37. cout<<" ";
  38.  
  39. }
  40.  
  41. for(int j = 0; j < (n-2*i); j++){
  42. cout<<"*";
  43. }
  44.  
  45. cout<<"\n";
  46. }
  47. }
  48.  
  49. int main()
  50. {
  51. int n;
  52. cin>>n;
  53. if(n%2 == 0){
  54. cout<<"please enter odd number"<<endl;
  55. }else{
  56.  
  57. pattern1(n);
  58. pattern2(n);
  59. pattern3(n);
  60. }
  61. return 0;
  62. }
Success #stdin #stdout 0s 5228KB
stdin
Standard input is empty
stdout
please enter odd number