how to writeh C++

hi !! can some one help me too Write a program like patchwork that takes two characters c and d, and a positive integer n and displays the following object made of the characters c and d over n
lines and n columns, as shown below.
(in for loop if that posible)

Sample 1:
Enter two characters and an integer: $ * 3

$*$
*$*
$*$

Sample 2:
Enter two characters and an integer: / \ 6
/\/\/\
\/\/\/
/\/\/\
\/\/\/
/\/\/\
\/\/\/
=======================================
i have tried something like this

==============================
#include
using namespace std;

int main() {


int n;

char c1, c2;

cout << "Enter two characters and an integer: " << flush;

cin >> c1 >> c2 >> n;
for (int i = 2; i < n; i++)
{
cout >> c1 >> c2;
}
return 0;

}
========================================
and

#include

using namespace std;

int main() {


int n;

char c1, c2;

cout << "Enter two characters and an integer: " << flush;

cin >> c1 >> c2 >> n;
for (int i = 2; i &lt; n; i++)
{
cout << c1 << c2 << endl;


for (int j = 2; j <= n-1 ; j++)cout << c2 << c1 ;cout << endl;}return 0;}=============================but it turn ot to be different to what i want and i dont know what to do next .
there will be two for loops, first for the number of rows you want to print.
second how many columns you want in a row.

for(row = 0; row < row_count; row++)
{
for(col = 0; col < col_count; col++)
{
//print slashes here, if the row is even then start with /
//if row is odd then start with \ try it.
}
}

correct??

hi thanks for the help ...this is wat i did but it still turn out to be different to what i expect ...can someone please hople to see what i did wrong
=====================
#include <iostream>

using namespace std;


int main()
{


int n;

char a, b;

cout << "Enter two characters and an integer: "<<flush;

cin >> a >> b >> n;



for(int row = 0; row < n; row++)
{
for(int col = 0; col < n; col++)
{
cout << b << a ;//print slashes here, if the row is even then start with /
cout << a << b ;//if row is odd then start with \ try it.
}
}
return 0;

}
close enough but a little change...
it should be like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void main()
{
	char a = '/';
	char b = '\\';


	int row_count = 6, col_count = 3;

	for(int row = 0; row < row_count; row++)
	{
		for(int col = 0; col < col_count; col++)
		{
			if((row % 2) == 0)
				cout << a << b;
			else
				cout << b << a;
		}
		cout << endl;
		
	}
}




Topic archived. No new replies allowed.