Facebook
From SURAJ PATWA, 1 Month ago, written in C++.
Embed
Download Paste or View Raw
Hits: 133
  1. #webkul pattern program round 1
  2. #pattern runs for odd number like min 3 , 5, 7 etc
  3. #here is ther pattern
  4. #for n==3
  5. *       *
  6. **     **
  7. ***@@@***
  8.    @@@
  9.    @@@
  10.    ***
  11.     *
  12. #for n==5
  13. *             *
  14. **           **
  15. ***         ***
  16. ****       ****
  17. *****@@@@@*****
  18.      @@@@@
  19.      @@@@@
  20.      @@@@@
  21.      @@@@@
  22.      *****
  23.       ***
  24.        *
  25. #and so on for n==7.....
  26. #here is the program
  27.  
  28.  
  29.  
  30.  
  31. #include <iostream>
  32. using namespace std;
  33. using std::cout;
  34. using std::cin;
  35. using std::endl;
  36.  
  37. int main(){
  38.     int n=3;
  39.    
  40.     // 1st part
  41.    
  42.     for(int i=0;i<n-1;i++){
  43.         for(int j=0;j<=i;j++){
  44.             cout<<'*';
  45.         }
  46.         for(int j=0;j<(3*n-(2+2*i));j++){
  47.             cout<<" ";
  48.         }
  49.          for(int j=0;j<=i;j++){
  50.             cout<<'*';
  51.         }
  52.         cout<<endl;
  53.     }
  54.    
  55.     //2nd part
  56.    
  57.     for(int i=0;i<1;i++){
  58.         for(int j=0;j<n;j++){
  59.             cout<<'*';
  60.         }
  61.         for(int j=0;j<n;j++){
  62.             cout<<"@";
  63.         }
  64.        for(int j=0;j<n;j++){
  65.             cout<<'*';
  66.         }
  67.         cout<<endl;
  68.     }
  69.    
  70.     //3rd Part
  71.    
  72.     for(int i=0;i<n-1;i++){
  73.         for(int j=0;j<n;j++){
  74.             cout<<" ";
  75.         }
  76.         for(int j=0;j<n;j++){
  77.             cout<<"@";
  78.         }
  79.         cout<<endl;
  80.     }
  81.    
  82.     //4th part
  83.    
  84.     for(int i=0;i<(n/2)+1;i++){
  85.         for(int j=0;j<(n+i);j++){
  86.             cout<<" ";
  87.         }
  88.         for(int j=0;j<(n-2*i);j++){
  89.             cout<<"*";
  90.         }
  91.         cout<<endl;
  92.     }
  93.    
  94.    
  95.    
  96.     return 0;
  97. }