This is from Discrete Mathematics and its Applications
Here is the definition of countable that the book uses 
and how to determine if two sets have the same cardinality

Here is the example that the book gave
Here is some work I added to the example

What I realized from the example was that the function n/2 would map an even positive integer to a positive integer and the function -(n - 1)/2 would map an odd positive integer to a negative/zero integer. I then showed that both functions were one to one and onto.
From this, I reasoned that there is a one to one correspondence from the set of positive integers to all integers because there are functions that map from an positive integer to an integer and that one positive integer will map to one unique integer and that every integer has a positive integer that will map to it.
Is this reasoning correct?
I tried to apply this idea to the next example the book provided that I didn't really understand. Here is the book example I don't really understand


Is there any equation that can be used to map a positive integer to a positive rational number, just like the equation in the last example to map a positive integer to an integer so I can go through my little proof to understand this better?