Pattern mountain problem

#include
using namespace std;
int main()
{
int n;
cin>>n;
int row=1;
while(row<=n){
int col=1;
int val=1;
while(col<=row){
cout<<val<<" “;
val++;
col++;
}
for(int s=1;s<=n-row;s++){
cout<<” ";
}

    val=row;
    int cnt =1;
    while(cnt<=row){
        cout<<val<<" ";
        cnt++;
        val--;
    }
    row++;
    cout<<endl;
}
return 0;

}

where I was wrong in this question please help me in the second part

please send me the code for it and explain me where I am wrong

please reply me fast

Your Mistakes

  1. you have to print two spaces

  2. in the last row starting value of val should be row-1
    otherwise val =row

Modified Code

the code you send its not correct please check it once and please explain me the logic what and how we did it

please send me the code and explain me the logic

expression for no of spaces (Between) is 2 * (n - row) -1

also the last line is different from other here 8 didn’t comes twice
so we have to handle it separately
like this

if(row==n && val == n)
                cout<<""; // print nothing
            else
                cout << val << " ";

you can check complete code here

Modified 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.