i think half of my code is right but there is some mistake in last line
Problem in the last row
#include using namespace std; int main() { int i,j,n; cin>>n; for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { cout<<j<<’\t’; } for(j=n+1;j>=2*i-1;j–) { cout<<’\t’; } for(j=i;j>=1;–j) { cout<<j<<’\t’; } cout<<endl; } return 0; }
If you want to share your code then please save your code on ide.codingblocks.com and then share its link.
code.cpp file saved with this name
Please copy and paste the link here so that i can check your code. After saving your coding copy and paste the URL here.
#include using namespace std; int main() { int i,j,n; cin>>n; for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { cout<<j<<’\t’; } for(j=n+1;j>=2*i-1;j–) { cout<<’\t’; } for(j=i;j>=1;–j) { if (j<n) cout<<j<<’\t’; else cout<<j-1<<’\t’ ; } cout<<endl; } return 0; }
@naaz It is not possible to check your code like this. I said you that please save your code on ide.codingblocks.com and share that link generated. The above link you shared is not working.
Are you facing any problem?
yes i am not getting the link of file
You can refer this code. Dry run with an example case to understand the logic.
I had explained the logic here Pattern mountain question