Answer to Question #348544 in C++ for Hhhh

Question #348544

5


4 5 4


3 4 5 4 3


2 3 4 5 4 3 2


1 2 3 4 5 4 3 2 1


2 3 4 5 4 3 2


3 4 5 4 3


4 5 4


5

1
Expert's answer
2022-06-06T08:57:15-0400
#include <iostream>


using namespace std;


int main()
{
	int n=5;
	for (int i = 0; i < 5; i++)
	{
		for (int j = n - i; j <= n; j++)
		{
			cout << j << " ";
		}
		for (int j = n-1; j >= n-i; j--)
		{
			cout << j << " ";
		}
		cout << endl;
	}
	for (int i = 0; i < 4; i++)
	{
		for (int j = i+2; j <= n; j++)
		{
			cout << j << " ";
		}
		for (int j = n -1; j >=2+i; j--)
		{
			cout << j << " ";
		}
		cout << endl;
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS