求c语言编程输入一个非回文数将其转为回文数。

[复制链接]
查看11 | 回复3 | 2010-12-30 14:37:32 | 显示全部楼层 |阅读模式
如输入56,将56+65得121是回文数。又如87,将87+78得165,再将165+561=726,再将726+627=1353,再将1353+3531=4884.最后输出计算步骤:87+78=165,165+561=726,726+627=1353,1353+3531=4884.

回复

使用道具 举报

千问 | 2010-12-30 14:37:32 | 显示全部楼层
#includeint hui(int x)//计算整数的回文并返回{
int he=0;
for(;;)
{if(x==0)break;
he+=x%10;
x/=10;
he*=10;
}
return he/10;
}int panduan(int x)//判断整数是否为回文,是返回1,否返回0{
int y=hui(x);
if(x==y)return 1;//是回文
else return 0;}int main(){
int x;
scanf("
回复

使用道具 举报

千问 | 2010-12-30 14:37:32 | 显示全部楼层
#include #include #include bool IsPalindrome(int num);int calc(int num);int main(){ int num,cont=0; scanf("%d",&num); while(!IsPali
回复

使用道具 举报

千问 | 2010-12-30 14:37:32 | 显示全部楼层
#include bool isPalindromic(int n){int temp = n;int mid = temp % 10;temp = temp / 10;while(temp ){
mid = mid * 10 + temp % 10; temp = temp /
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行