Pattern triange

i am getting right sample output but it is showing wrong in some test cases .i dont understand what is wrong in my code .how can i verify this?
#include
using namespace std;
int main()
{
int N, j, k;
cin>>N;
for (N = 1; N <= 4; N++)
{
k = N;
for (j = 1; j <= 7; j++)
{
if (j>=5-N && j<=3+N)
{
cout<<k;
j<4?k++:k–;
}
else
{
cout << " “;
}
cout<<”\t";
}

    cout << endl;
}
return 0;

}

hello @mokshi.14
ur logic is not generic,

u have hardcoded the values and becuase of that it is failing test case.
generalise ur logic so that it works for every cases

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.