`

学习笔记(2)

阅读更多

随机输入一个数,判断它是不是对称数(回文数)(如3,121,12321,45254)。不能用字符串库函数

 

public boolean  symmetry(long n){

       int i,temp; 
       i = n; 
       temp = 0;
       while(i){ 
            temp = temp *10 +i%10;
            i/=10;
        } 
      return (temp == n); 
}

  

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics