nested for loops

so i need to make this:
(the pipes line up with the "+" signs)
+===+===+
| | |
| | |
| | |
+===+===+
| | |
| | |
| | |
+===+===+

And the problem is making the "pipes" go down by three. i am trying to make it so that the random number generator, generates a number by which to scale the output by. i cannot figure it out. thanks if you can help.
if it doesn't work that way let me know too.
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;
void windows();

int main()
{
	 windows();	
	return 0;
}

void windows()

{
	int a;
	srand(time(0));
	a = rand()%7+1;

	int i = a;
	int f = a;
	int z = a;
	
	for (i=0; i < a; i++)
	{
		cout << "+";
		if (i < a - 1)
		{
			for (z = 0; z <a; z++)
				cout << "=";
		}
	}
	cout << endl;

	
	
	for (i=0;i<a; i++)
	{
		cout << "|";
		
			for ( f=0; f < a; f++)
			{
				cout << " ";

			}
		
	}
	cout <<endl;
	
	
	
	for (i=0; i<a; i++)
	{
		cout << "+";
		if (i < a - 1)
		{
			for(z=0; z < a; z++)
				cout << "=";
		}
	}
	cout << endl;

}
Last edited on
@captSlo87

You just needed more for loops.

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Nested for loops.cpp : main project file.

#include <iostream>
#include <ctime>
#include <cstdlib>

using namespace std;
void windows();

int main()
{
	windows();
	return 0;
}

void windows()

{
	srand((unsigned)time(0));
	int a = 1 + rand() % 7;

	// Removed, as they are not being used. Just the variable was, NOT the values
	//int i = a;
	//int f = a;
	//int z = a;

	for (int i = 0; i < a; i++)
	{
		cout << "+";
		if (i < a - 1)
		{
			for (int z = 0; z <a; z++)
				cout << "=";
		}
	}
	cout << endl;
	for (int twice = 1; twice < a; twice++)
	{
		for (int x = 0; x < 3; x++)// Make box, 3 high
		{
			for (int i = 0; i < a; i++)
			{
				cout << "|";

				for (int f = 0; f < a; f++)
				{
					cout << " ";
				}
			}
			cout << endl;
		}

		for (int i = 0; i < a; i++)
		{
			cout << "+";
			if (i < a - 1)
			{
				for (int z = 0; z < a; z++)
					cout << "=";
			}
		}
		cout << endl;
	}
}
oh my god! thank you!
Topic archived. No new replies allowed.