Skip to main content

Pattern in C++

 


#include<bits/stdc++.h>

using namespace std;

int main()
{



    /*
        ****
        *  *
        *  *
        *  *
        ****
    */
    for (int i = 1; i <=6; i++)
    {
        for (int j = 1; j <=5; j++)
        {
            if(i == 1 || i==6 || j==1 ||j==5){
                cout<<"*";
            }
            else {
                cout<<" ";
            }
        }
        cout<<endl;
    }


    /*
       * * * * *
       * * * *
       * * *
       * *
       *
    */
    // for (int i = 5; i >-1; i--)
    // {
    //     for (int j = 1; j<=i; j++)
    //     {
    //         cout<<"* ";
    //     }
    //     cout<<endl;
    // }
   
   
    /*
        *
        * *
        * * *
        * * * *
        * * * * *
    // */
    // for(int i = 1; i<=5; i++){
    //     for (int j = 1; j <=i; j++)
    //     {
     
    //         cout<<"* ";
    //     }
    //     cout<<endl;
    // }
   

    /*
                *
              * *
            * * *        
          * * * *
        * * * * *
    */
    // for (int i = 1; i <=5; i++)
    // {
    //     for (int j = 1; j <=5; j++)
    //     {
    //         if(j<=5-i){
    //             cout<<" ";
    //         }
    //         else{
    //             cout<<"*";
    //         }
    //         cout<<" ";
    //     }
    //     cout<<endl;
    // }
   
    // int a = 1;
    // for (int i = 1; i <=5; i++)
    // {
    //     for(int j = 1; j<=i;j++)
    //     {
    //         cout<<a<<" ";
    //         a++;
    //     }
    //     cout<<endl;
    // }
   
    return 0;
}

Comments