What's the code?

This is the output: https://app.box.com/s/xsncghj8zetyeq4a04fb
>The third part: Input width and height and it gives a pattern of diamonds

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
#include<iostream>
#include<iomanip>
using namespace std;

int w, h, s;
void diamond();

int main()
{
	cout << "Enter width and height: ";
	cin >> w >> h;
	diamond();

	system("pause>0");
	return 0;
}

void diamond()
{
	//width
	for (int a = 1; a <= w; a++){
		cout << "  X  " << setw(3);
	}
	cout << endl;

	for (int a = 1; a <= w; a++){
		cout << " / \\ ";
	}
	cout << endl;

	for (int a = 1; a <= w; a++){
		cout << "/   \\";
	}
	cout << endl;

	for (int a = 1; a <= w; a++){
		cout << "\\   /";
	}
	cout << endl;
	
	for (int a = 1; a <= w; a++){
		cout << " \\ / ";
	}
	cout << endl;

	for (int a = 1; a <= w; a++){
		cout << "  X  " << setw(3);
	}
	cout << endl;
//no height yet...
}


My current output:
Enter width and height: 2 3
X X
/\ /\
/ \/ \
\ /\ /
\/ \/
X X

What it should be:
X X
/\ /\
/ \/ \
\ /\ /
\/ \/
X X
/\ /\
/ \/ \
\ /\ /
\/ \/
X X
/\ /\
/ \/ \
\ /\ /
\/ \/
X X
UPDATE:
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
void square()
{
	for (int a = 1; a <= w; a++){
		cout << "+";
		line('-', w);
	}
	cout << "+" << endl;

	for (int a = 1; a <= w + 1; a++){
		cout << "|";
		line(' ', w);
	}
	cout << " " << endl;

	for (int a = 1; a <= w + 1; a++){
		cout << "|";
		line(' ', w);
	}
	cout << endl;

	for (int a = 1; a <= w; a++){
		cout << "+";
		line('-', w);
	}
	cout << "+" << endl;
}

//void honeycomb()
//{
//	for (int a = 1; a <= h; a++){
//		
//	}
//}

void line(char ch, int ctr)
{
	for (int i = 0; i < w; i++)
		cout << ch;
}

void diamond()
{
	//width
	for (int a = 1; a <= w; a++){
		cout << "  X  " << setw(3);
	}
	cout << endl;

	for (int a = 1; a <= w; a++){
		cout << " / \\ ";
	}
	cout << endl;

	for (int a = 1; a <= w; a++){
		cout << "/   \\";
	}
	cout << endl;

	for (int a = 1; a <= w; a++){
		cout << "\\   /";
	}
	cout << endl;
	
	for (int a = 1; a <= w; a++){
		cout << " \\ / ";
	}
	cout << endl;

	for (int a = 1; a < w; a++){
		cout << "  X  " << setw(3);
	}
	cout << endl;
	//height
	for (int a = 1; a < h; a++){
		cout << " / \\ " << endl
			<< "/   \\" << endl
			<< "\\   /" << endl
			<< " \\ / " << endl
			<< "  X  " << endl;
	}
}

NEW OUTPUT:
X X
/\ /\
/ \/ \
\ /\ /
\/ \/
X
/\
/ \
\ /
\/
X
/\
/ \
\ /
\/
X
Last edited on
lolwut?
A user will input the width and height and it will output the number of diamonds per loop..
width=5= 5 diamonds
height=6=6 diamonds
It's like a table but it's a symbol.
Just think of it as squares i guess?
if width=5
and
height=6
then,
___ ____ ____ ___ ___
|__||___||___||___||___|
___ ____ ____ ___ ___
|__||___||___||___||___|
___ ____ ____ ___ ___
|__||___||___||___||___|
___ ____ ____ ___ ___
|__||___||___||___||___|
___ ____ ____ ___ ___
|__||___||___||___||___|
___ ____ ____ ___ ___
|__||___||___||___||___|
>think of the squares as a diamond xD
//hope i made it clearer :P
@Vandalism

You just needed one more for loop, like so.

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
#include<iostream>
#include<iomanip>

using std::cout;
using std::cin;
using std::endl;
using std::setw;

void diamond(int wide, int high);

int main()
{
 int w, h, s;
 cout << "Enter width and height: ";
 cin >> w >> h;
 diamond(w,h);

 system("pause");
 return 0;
}

void diamond(int w, int h)
{
 //width
 for (int a = 0; a < w; a++){
	cout << "  X  " << setw(3);
 }
 for (int x=0;x<h;x++)// high
 {
	cout << endl;

	for (int a = 0; a < w; a++){
	 cout << " / \\ ";
	}
	cout << endl;

	for (int a = 0; a < w; a++){
	 cout << "/   \\";
	}
	cout << endl;

	for (int a = 0; a < w; a++){
	 cout << "\\   /";
	}
	cout << endl;

	for (int a = 0; a < w; a++){
	 cout << " \\ / ";
	}
	cout << endl;

	for (int a = 0; a < w; a++){
	 cout << "  X  " << setw(3);
	}
 }
 cout << endl;
}
Yay! Thank you! :D
Here's the final and correct code with added codes in it... It's the first and third output in the link(Haven't figured out the second output working on it)

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include<iostream>
#include<iomanip>
using namespace std;

int w, h, s;

void line(char, int);
void square();
//void honeycomb();
void diamond();

int main()
{
	cout << "Enter width: ";
	cin >> w;
	square();
	/*cout << "Enter width and height: ";
	cin >> w >> h;
	honeycomb();*/
	cout << "Enter width and height: ";
	cin >> w >> h;
	diamond();

	system("pause>0");
	return 0;
}

void square()
{
	for (int a = 1; a <= w; a++){
		cout << "+";
		line('-', w);
	}
	cout << "+" << endl;

	for (int a = 1; a <= w + 1; a++){
		cout << "|";
		line(' ', w);
	}
	cout << " " << endl;

	for (int a = 1; a <= w + 1; a++){
		cout << "|";
		line(' ', w);
	}
	cout << endl;

	for (int a = 1; a <= w; a++){
		cout << "+";
		line('-', w);
	}
	cout << "+" << endl;
}

//void honeycomb()
//{
//	for (int a = 1; a <= h; a++){
//		
//	}
//}

void line(char ch, int ctr)
{
	for (int i = 0; i < w; i++)
		cout << ch;
}

void diamond()
{
	//width
	for (int a = 1; a <= w; a++){
		cout << "  X  " << setw(3);
	}

	for (int x = 0; x < h; x++)// high
	{

		cout << endl; 

		for (int a = 0; a < w; a++){
			cout << " / \\ ";
		}
		cout << endl;

		for (int a = 0; a < w; a++){
			cout << "/   \\";
		}
		cout << endl;

		for (int a = 0; a < w; a++){
			cout << "\\   /";
		}
		cout << endl;

		for (int a = 0; a < w; a++){
			cout << " \\ / ";
		}
		cout << endl;

		for (int a = 0; a < w; a++){
			cout << "  X  " << setw(3);
		}
	}
	cout << endl;
}
Hallo! This is the final code... done the 3 outputs.. I'm proud of myself.. xD
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include<iostream>
#include<iomanip>
using namespace std;

int w, h, s;

void line(char, int);
void square();
void honeycomb();
void diamond();

int main()
{
	cout << "Enter width: ";
	cin >> w;
	square();
	cout << "Enter width and height: ";
	cin >> w >> h;
	honeycomb();
	cout << "Enter width and height: ";
	cin >> w >> h;
	diamond();

	system("pause>0");
	return 0;
}

void square()
{
	for (int a = 1; a <= w; a++){
		cout << "+";
		line('-', w);
	}
	cout << "+" << endl;

	for (int a = 1; a <= w + 1; a++){
		cout << "|";
		line(' ', w);
	}
	cout << " " << endl;

	for (int a = 1; a <= w + 1; a++){
		cout << "|";
		line(' ', w);
	}
	cout << endl;

	for (int a = 1; a <= w; a++){
		cout << "+";
		line('-', w);
	}
	cout << "+" << endl;
}

void honeycomb()
{
	for (int a = 1; a <= w; a++){
		cout << " ___    " << setw(3);
	}

	for (int x = 0; x < h; x++)// high
	{

		cout << endl;

		for (int a = 0; a < w; a++){
			cout << "/   \\___";
		}
		cout << endl;

		for (int a = 0; a < w; a++){
			cout << "\\___/   ";
		}
	}
	cout << endl;
}

void line(char ch, int ctr)
{
	for (int i = 0; i < w; i++)
		cout << ch;
}

void diamond()
{
	//width
	for (int a = 1; a <= w; a++){
		cout << "  X  " << setw(3);
	}

	for (int x = 0; x < h; x++)// high
	{

		cout << endl; 

		for (int a = 0; a < w; a++){
			cout << " / \\ ";
		}
		cout << endl;

		for (int a = 0; a < w; a++){
			cout << "/   \\";
		}
		cout << endl;

		for (int a = 0; a < w; a++){
			cout << "\\   /";
		}
		cout << endl;

		for (int a = 0; a < w; a++){
			cout << " \\ / ";
		}
		cout << endl;

		for (int a = 0; a < w; a++){
			cout << "  X  " << setw(3);
		}
	}
	cout << endl;
}
@Vandalism

Good job, and you should feel proud of yourself. Program looks great.
@whitenite1

Thank you! :)
Topic archived. No new replies allowed.