题目:随机输入一个数,判断它是不是对称数(回文数)(如3,121,12321,45254)。不能用字符串库函数
自己做了下,代码实现:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
int
num
=
Convert.ToInt32(Console.ReadLine());
int min = 0 , max = num;
while (max > 0 )
{
min = min * 10 + max % 10 ;
max = max / 10 ;
}
if (min == num)
Console.Write( " 是回文数 " );
else
Console.Write( " 不是回文数 " );
int min = 0 , max = num;
while (max > 0 )
{
min = min * 10 + max % 10 ;
max = max / 10 ;
}
if (min == num)
Console.Write( " 是回文数 " );
else
Console.Write( " 不是回文数 " );
很简单的。