Surjective continuous function I am trying to learn how can construct onto continuous function from rational (irrational) numbers to integers. I believe, I have an example helpfully it is true 
Example : let $\mathbb Q$ denote the rational numbers and $\mathbb Z$ denoted the integers number. Suppose function defined by $f(x)=[x]$ , that is, $f$ the Greatest integer function. I have two questions :
(1) Is it still true for irrational function 
(2) if there are more interesting examples 
 A: You can write $R=\bigcup_nI_n= \{[n\pi,(n+1)\pi], n\in Z\}$ define $f:Q\rightarrow Z$ such that the  restriction of $f$ to $[n\pi,(n+1)\pi]\cap Q$ is the constant function $n$.
Let $I$ be the set of irrational numbers.
$R=\bigcup_nI_n= \{[n,(n+1)], n\in Z\}$ define $f:Q\rightarrow Z$ such that the  restriction of $f$ to $[n,(n+1)]\cap I$ is the constant function $n$.
A: Every subset of $Z$ is open so any $f:X\to Z$ is continuous iff $f^{-1}\{n\}$ is open in $X$ for every $n\in Z.$
For $X=R$  \  $Q$ and $f(x)=[x]$ (the largest integer not exceeding $x$) we have $f^{-1}\{n\}=[n,n+1)\cap X=(n,n+1)$  \  $Q$ which is open in $R$  \  $Q,$ and not empty, so $f$ is a continuous surjection .
For $X=Q$ and $f(x)=[x],$ the set $f^{-1}\{0\}=[0,1)\cap Q$  is not open in $Q,$ because any nbhd of $0$ in the space $Q$ has  a subset $(-t,t)\cap Q$ for some $t>0$ and hence the nbhd contains negative numbers. So $f$ is not continuous.
Let $r$ be positive and irrational. For $n\in Z$ and $x\in (nr,(n+1)r)\cap Q$ let $g(x)=n.$ For every  $x\in Q$ there is a unique $n\in Z$ such that $x\in (nr,(n+1)r),$ so dom$(g)=Q$ and $g$ is well-defined. Now $g^{-1}\{n\}= (nr,(n+1)r)\cap Q$ is open in $Q$ and not empty, so $g$ is a continuous surjection.
