Problem with looping

can anyone help me solve problem with printing a diamond..
i just know the first that we should make a loop for x times, right??
and then i don't know what should i do ...
Last edited on
A diamond made out of text? I would use two for loops, one for the getting bigger part (tip to the middle), and one for getting smaller. Then each if those will need two loops inside.
1
2
3
4
5
6
7
8
9
// tip to middle
for (?) {
   for (?)
      cout << " ";
   cout << "/";
   for (?)
      cout << " ";
   cout << "\";
} 
win 32 console app, remember you will need to use two \ because it's special in a string, ( like \n for newline )

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

using namespace std;

int main()
{

	cout << " . " << endl;
	cout << "/ \\ " << endl;
	cout << "\\ / " << endl;
	cout << " ` " << endl;
return 0;
}


I don't think using a for loop would help
Last edited on
Please search the site before posting a question.

http://www.cplusplus.com/forum/beginner/3752/
thx, my problem solve..
Topic archived. No new replies allowed.