当前位置:网站首页>生成回文数
生成回文数
2022-08-04 22:25:00 【拉的很多】
题目描述
本题为填空题,只需要算出结果后,在代码中使用输出语句将所填结果输出即可。
所谓回文数就是左右对称的数字,比如:
585,5885,123321...
当然,单个的数字也可以算作是对称的。
小明发现了一种生成回文数的方法: 比如,取数字 1919,把它与自己的翻转数相加: 19 + 91 = 110,如果不是回文数,就再进行这个过程:110+011=121 这次是回文数了。200 以内的数字中,绝大多数都可以在 30 步以内变成回文数,只有一个数字很特殊,就算迭代了1000 次,它还是顽固地拒绝回文!
请你输出该顽固数字。
思路:
主要了解 怎么如何进行逆序
long long sum = 0;
while(n)
{
int t = n % 10;
sum = sum * 10 + t;
n = n/10;
}
#include<stdio.h>
long long fan(long long n)
{
long long sum = 0;
while(n)
{
int t = n % 10;
sum = sum * 10 + t;
n = n/10;
}
return sum;
}
int main()
{
long long n;
int i,j;
for(i=1;i<200;i++)
{
n = i;
for(j=0;j<30;j++)
{
if(n != fan(n))
{
n += fan(n);
}
else
break;
}
if(j >= 30)
printf("%d\n",i);
}
return 0;
}
边栏推荐
- "Jianzhi offer" brush title classification
- 质量管理大师爱德华·戴明博士经典的质量管理14条原则
- Redisson
- Several ways for rk3399 to drive screen parameters
- 【论文笔记KDD2021】MixGCF: An Improved Training Method for Graph Neural Network-based Recommender Systems
- 基于事实的结果
- 基于声卡实现的音频存储示波器,可作为电磁学实验的测量仪表
- PowerBI真经连续剧
- The upgrade and transformation plan of the fortress machine for medium and large commercial banks!Must see!
- VSCode—常用快捷键(持续记录
猜你喜欢
随机推荐
打卡第 2 天: urllib简记
CountDownLatch使用及原理
PHP(3)
七夕,当爱神丘比特遇上牛郎和织女
SQL Server calls WebService
To Offer | 03. Repeat Numbers in the array
"Jianzhi offer" brush title classification
【TCP/IP 四 IP 网际协议】
基于事实的结果
The upgrade and transformation plan of the fortress machine for medium and large commercial banks!Must see!
打卡第 1 天:正则表达式学习总结
七夕特制:《牛郎会织女》
puzzle(022.1)黑白迭代
Deep Learning RNN Architecture Analysis
字节跳动秋招提前批高频面试问题汇总!(内附答案!)
Domestic PMP certificate of gold content how
【项目实战】仿照Room实现简单管理系统
直播带货为农产品开拓销售渠道
How to right use of WebSocket in project
promise详解


![Rt-thread [二] 系统初始化流程](/img/46/6e2942e4c18c0220378050205e6528.png)





![MQTT[一]基础知识介绍](/img/25/3ba24127e2258902b2d5ecc7c3727b.png)
