Define f(x) by if is a rational number expressed in lowest terms, and f(x)=0 for irrational x. (I've sometimes heard this called the ``ruler'' function, since its graph vaguely resembles the markings on a ruler.) Then f has the surprising property that it is continuous at all irrationals and discontinuous at all rationals. It's easy to believe that f is discontinuous at all rationals, since for a rational number , there are irrational numbers x arbitrarily close to , but f(x)=0 is not getting close to .
It's a bit harder to see that f is continuous at any irrational x. Roughly speaking, there's no way that rational numbers can approach an irrational number x without their denominators going to infinity, so that f approaches 0. More formally, take any . There is an integer q with . Look at all the rational numbers of the form . Since x is irrational, it is not one of these numbers. Because of the way the numbers , p=0, , , appear on the number line, there is a closest number in this set to x (a careful proof of this fact uses properties of the integers). Take to be smaller than the distance from x to the closest number of the form . Then no rational number within of x may be written as a fraction with denominator less than or equal to q, so all numbers with of x must have their function values within of f(x), so f is continuous at any irrational x.