References of Computer Programming

  1. Algorithms in C++(3rd edition) by Robert Segewick.
  2. C++ Primer (4th edition) by Stanley B.Lippman, Josae Lajoie, Barbra, E. Moo.
  3. C++ How to Program (5th edition) by P.J. Deitel.
  4. Computer Networks (3rd edition) by Andrew S. Tanenbaum.
  5. Computer Systems A Programmer's Perspective By Randal E. Bryant

Spiral Numbers

Print spiral number array like this:

7 8 9 10
6 1 2 11
5 4 3 12

Given coordinates of a point, find the corresponding number residing on it.

There are many solutions to this problem. For example, find the number by looking for the relation(function) between the number and its coordinates. The code below solves the problem without using such kind of relation. Of course, the cost is the increase of running time.