Rounding numbers in matrix over reals

Given $ n \times n$ matrix of real numbers, such that total value in every matrix row and column is integer-valued, find a way to round every number in matrix so that row and column totals do not change.

Is it possible to round all numbers is such way? What could be an algorithm for the problem? (it looks like we should use some kind of graph that represents relation between fractional parts of the numbers)