Nested Loops

Good evening good people! I need an example of a nested loop or modulus in this order 1-3-5-3-1 using stars in a diamond shape. thank you so much!

closed account (SECMoG1T)
What have you tried ? Do you have an idea of how to do 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
// for loop diamond
#include <iostream>
using namespace std;

int main()
{
	int row = 9;  // odd number row
	int r = (row+1)/2;  
	int s = 1;
	for (int s=1; s<2*r; s++)
	{
		if(s<=r)
		{
		  for(int i= r-s; i>0; i-- )
		    cout << " ";
		  for(int i= 2*s-1; i>0; i-- )
		    cout << "*";			
		}
		else
		{
		  for(int i= s-r; i>0; i-- )
		    cout << " ";
		  for(int i= 4*r-2*s-1; i>0; i-- )
		    cout << "*";			
		}					

		cout << endl;		
	}
	
cin.ignore();
return 0;	
}
Forgive us if we are reserved on providing an example, this is a classic first year class assignment. Little Bobby Tables gave you some pseudo code here: http://www.cplusplus.com/forum/lounge/149697/#msg782424

You did ask if you could give what you already have first, which would be great. remember to put your code in code-tags ['code']['/code'] (without the single quotes on them. just the words and the forward slash on the second one)
we dont do others assignment. sorry. can you show us the youve done so far?
even if we show you an example you wouldnt understand it
Topic archived. No new replies allowed.