Failed Test Cases

Hello Sir!

I’m getting correct output. But the program is not able to pass test cases.

Can you help me out?

Thank you.

Hi Prabhjot. kindly share ur code

#include

using namespace std;

int main()
{
int n; cin >> n;
int nsp = (n-1);
int nst = 1;

int arr[n][n];

for(int i = 1; i <= n; i++)
{
    for(int csp = 1; csp <= nsp; csp++)
        cout << " ";
        
    for(int cst = 1; cst <= i; cst++)
    {
        if((cst == 1) || (cst == i))
            arr[i][cst] = 1;
        else
        {
            arr[i][cst] = arr[i-1][cst-1] + arr[i-1][cst];
        }
        cout << arr[i][cst] << " ";
    }
    
    cout << endl;
    nsp--;
}


return 0;

}

Hi. in output format here one space should be there as highlighted but ur code is missing that. try to figure that out.
image

also u can refer this https://ide.codingblocks.com/s/581632
there is no need to use extra space as u have done by creating a 2d matrix

Ok. But which part of code should be changed then?

for initial spacing use this
image

i have corrected ur code

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.

1 Like

Thank you sir. Got it.