Prove that this function is onto and one-to-one $f:Z \rightarrow Z$
$f(x) = x-5$ , when $x$ is odd
$f(x) = x+3$ ,  when $x$ is even
It seems that it is not onto, because not all integers are covered, but how do you show this?

This is indeed onto, 
Pick any $a\in\mathbb{Z}$. 
if $a$ is odd we know that $a - 3$ is even (since $a - 2$ is clearly odd) so $f(a - 3) = a$. 
if $a$ is even we know that $a + 5$ is odd (since $a + 4$ is clearly even) so $f(a + 5) = a$. 
This function is also one to one, and I leave this partially to you, to see this note that for odd $x$, $f(x)$ only hits even numbers and never hits the same number twice. And for even $x$ this only hits odd numbers.
