这道题目挺好,我也写了一份代码  
http://www.cnblogs.com/pk28/p/7470030.html