Double sided arrow

last test case is pending

#include
using namespace std;
int main() {
int no;
cin>>no;
int n=(no+1)/2;
for(int i=1;i<=2n-2;i++)
cout<<" ";
cout<<“1 \n”;
for(int i=1;i<n;i++)
{
for(int k=1;k<=2
(n-i-1);k++)
cout<<" “;
for(int k=i+1;k>=1;k–)
cout<<k<<” “;
for(int k=1;k<=2i-1;k++)
cout<<" “;
for(int k=1;k<=i+1;k++)
cout<<k<<” “;
cout<<”\n";
}
for(int i=n-2;i>=1;i–)
{
for(int k=1;k<=2
(n-i-1);k++)
cout<<” “;
for(int k=i+1;k>=1;k–)
cout<<k<<” “;
for(int k=1;k<=2i-1;k++)
cout<<" “;
for(int k=1;k<=i+1;k++)
cout<<k<<” “;
cout<<”\n";
}
for(int i=1;i<=2
n-2;i++)
cout<<” ";
cout<<"1 ";
return 0;
}
Close

your code was not working for input n=1 it should print 1 but it is printing 1 1 so make a separate case when n=1 print 1 and return 0 rest code is fine I have modified your code https://ide.codingblocks.com/s/216625