jeudi 14 janvier 2021

I want to print the upper half of the butterfly pattern. What is wrong with my code?

This pattern I want to print

#include <iostream>
using namespace std;

int main() {
    // your code goes here

    for(int j=1;j<= 4;j++)
    {
        for(int i=1;i<=8;i++)
        {if (i<=j)
            cout<<"* ";
            else if (i+j >= 9)
            cout<<"* ";
            else
            cout<<" ";
        }
            cout<<endl;

    }
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire