[cs13001] Lab 3 Figures

Mikhail Nesterenko mikhail at cs.kent.edu
Fri Sep 14 23:10:26 EDT 2012


> process of completing the second half of lab 3 and for the life of me can
> not figure out what to do. I checked the instructions multiple times and
> referenced the book and the powerpoints, but still can't figure out what to
> do. Sean said something during the lab about nesting an if statement in the
> inner loop, but I'm not entirely sure what he meant. If you could just
> possibly point me in the right direction, I would be immensely grateful.

Let us address the first figure - the rectangle. The others are
similar.  Consider the odometer program that is given as a reference
example in the lab. Specifically, the nested loops code:

 // nested loops
 // printing odometer values for the complete tens of distance
 // ex: for distance of 55, printing from 00 to 49
 for (int i = 0; i < tens; i++)  // outer loop
     for (int j = 0; j < 10; j++)  // inner loop
	 cout << i << j << endl;

Think how, instead of the values "i" and "j", the inner loop prints a
star. Now, the inner loop would then keep track of the stars printed
across the line and the outer loop would move the output to the next
line and keep track of how many lines of stars (or inner loop
invocations) is to be printed.

Thanks,
--
Mikhail


More information about the cs13001 mailing list