Facebook
From SURAJ PATWA, 1 Month ago, written in C++.
Embed
Download Paste or View Raw
Hits: 130
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4.     int n=5;
  5.     //1st part
  6.     for(int i=0;i<(n/2+1);i++){
  7.         for(int j=0;j<(n+2-i);j++){
  8.                 std::cout<<" ";
  9.         }
  10.        for(int j=0;j<(2*i +1);j++){
  11.            std::cout<<"*";
  12.        }
  13.        for(int j=0;j<(2-i);j++){
  14.            std::cout<<" ";
  15.        }
  16.        
  17.         std::cout<<std::endl;
  18.     }
  19.    
  20.     //2nd part
  21.     for(int i=0;i<(n-2);i++){
  22.         for(int j=0;j<n;j++){
  23.         std::cout<<" ";
  24.         }
  25.         std::cout<<"@";
  26.         for(int j=0;j<n-2;j++){
  27.             std::cout<<" ";
  28.         }
  29.          std::cout<<"@";
  30.          
  31.              std::cout<<endl;
  32.  
  33.        
  34.     }
  35.    
  36.     //3rd part
  37.    
  38.     for(int i=0;i<1;i++){
  39.         for(int j=0;j<n;j++){
  40.             std::cout<<"*";
  41.         }
  42.         std::cout<<"@";
  43.         for(int j=0;j<n-2;j++){
  44.            std:: cout<<" ";
  45.         }
  46.         cout<<"@";
  47.          for(int j=0;j<n;j++){
  48.             std::cout<<"*";
  49.         }
  50.        
  51.         std::cout<<endl;
  52.        
  53.     }
  54.    
  55.     //4th part
  56.     for(int i=0;i<n/2;i++){
  57.         for(int j=0;j<=i;j++){
  58.            std:: cout<<" ";
  59.         }
  60.         for(int j=0;j<n-(2*(i+1));j++){
  61.             std::cout<<"*";
  62.         }
  63.         for(int j=0;j<n+2*(i+1);j++){
  64.             std::cout<<" ";
  65.         }
  66.          for(int j=0;j<n-(2*(i+1));j++){
  67.             std::cout<<"*";
  68.         }
  69.         std::cout<<endl;
  70.     }
  71.    
  72.    
  73. }