随机输入一个数,判断它是不是对称数(回文数)(如3,121,12321,45254)。不能用字符串库函数
1 bool Symmetry(int input) 2 { 3 int number = input; 4 int reverse = 0; 5 while (number) 6 { 7 reverse = reverse*10 + number%10; 8 number = number/10; 9 } 10 return reverse == input; 11 }
时间: 2024-12-29 11:31:44