Let
x-----------------> books in the first shelf
y-----------------> books in the second shelf
z-----------------> books in the third shelf
we know that
x+y+z=158-------------> equation (1)
x=y-8---------> y=x+8 -------> equation (2)
x=z+5--------> z=x-5 --------> equation (3)
substitute (2) and (3) in (1)
x+(x+8)+(x-5)=158--------> 3x=155----------> x=51.7
the number of books in the first shelf (x=51.7) is not a whole number
therefore
the answer is
Is not possible to place the amount of 158 books in the amounts indicated in the problem