Help with displaying a pattern

I need help with this problem:

"Ask the user to enter a positive number, the number will determine the number of rows in the following patterns- user enters 3- use for loop

+ +++
++ ++
+++ +
"

What is the pattern doing?
Last edited on
closed account (DoLCX9L8)
Have you tried anything so far?
This is what I have so far. I believe this is what the pattern is doing..
using the example: If a user enters 3 the program should display a pattern such as this (I used numbers instead of "+" as an ex here just so it's easier to visualize. The "*" indicates where I need help)
             1         ***
             12         **
             123         * 


and this is what I have so far
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
#include<conio.h>
using namespace std;

void main()
{
	system("cls");
	int i, j, n, s;
	cout << "Enter a positive number : ";
	cin >> n;
	
	system("cls");

	for (i = 1; i <= n; i++)
	{
		s = n - i;
		while (s != 0)
		{
			s--;
			
		}
		for (j = 1; j <= i; j++)
		{
			cout << "+";
		}
		cout << endl;
	}
	_getch();
}
Last edited on
Topic archived. No new replies allowed.