4 ms·
This problem appears in the Deitel and Deitel book "C++ How to Program" as well as in their Java book. It's a great exercise that challenges CS students every
by johnohara 16y ago
This problem appears in the Deitel and Deitel book "C++ How to Program" as well as in their Java book.
It's a great exercise that challenges CS students every year and does a very good job at teaching nested loops.
Later in the same set of exercises is the four triangles problem that ties increment and decrement operators to the use of nested loops. It's one of my personal favorites.
CS students who legitimately complete these exercises always do well with chapter 4 (Arrays, Simpletron), chapter 5 (pointers) and chapter 6 (structs and classes) and come away with insight and a sense of confidence that echoes for a long time.
It is literally one of those defining problems that separates those who are serious from those who are not.
The responder at comp.lang.c knew that. Kudos to him.
- kmt 16y agoExactly. I'm surprised to see many people here saying that the responder was unhelpful or rude. I think that the answer was not only fascinating but also responsible, pedagogical and, in a way, even compassionate.
- cabalamat 16y agoNot rude, but has waaaay too much time on his hands!
- cabalamat 16y ago> It is literally one of those defining problems that separates those who are serious from those who are not. It's up there with FizzBuzz; anyone who can't do it simply isn't up to being a programmer.