jeudi 11 février 2021

I want to draw the pattern which is shown in image i attached but i can't build the logic [closed]

#include<iostream>
using namespace std;
int main()
{
    int i,j,k;
    for(i=1;i<=6;i++)
    {
        k=10;
        for(j=1;j<=11;j++)
        {
        cout<<" ";
        if(j>=i && j<=12-i)
        {
            cout<<k;
            k--;
        }
        else
            cout<<" ";
    }
    cout<<"\n";
}
return 0;
}

Image:
enter image description here I wrote this code but it is not working as expected as my logic is not completely correct.

Aucun commentaire:

Enregistrer un commentaire