#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int space=n-2;
for (int j = 0; j < n; j++)
{
for (int i =0; i <=space; i++)
{
cout<<" ";
}
space--;
int k=1;
for (int o = 0; o <=j; o++)
{
cout<<k<<" ";
k=k*(j-o)/(o+1);
}
cout<<endl;
}
return 0;
}
Is there something wrong with spaces, i have printed exact output as in question
please update the pattern spaces in question explaination, its so frustating
i was revising the same question now when i written the code and tried submitting it is showing wrong answer
@sagar_aggarwal there are 3 successful submissions, 1 in June and 2 of today…they scored 100 points which means they passed all the test cases
i am talking about today
This code is passing all testcases but the output here is not same as in question when compared with spaces to be printed
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int space=n;
for (int i = 0; i < n; i++)
{for (int k=space; k >0; k--)
{
cout<<" ";
}
space=space-1;
int p=1;
for (int k = 0; k <= i; k++)
{
cout<<p<<" ";
//important
//print pascal
p=p*(i-k)/(k+1);
}
cout<<endl;
}
return 0;
}
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.