当前位置:网站首页>Using C language to realize palindrome number
Using C language to realize palindrome number
2022-07-05 17:05:00 【Daily study of bald girls】
use C Language implementation palindromes
LeetCode Brush problem Day 1
subject : Enter an integer x , If x Is a palindrome integer , return true ; otherwise , return false .
Topic link :https://leetcode-cn.com/problems/palindrome-number/
Palindrome number concept :
Palindrome number refers to From left to right 、 From right to left Are the same integer .
Such as :343,232,898,123321 All palindromes ;
221,987,456,98765 Not even palindromes .
The code is as follows :
#include<stdio.h>
bool huiwenshu(long int x) // Palindrome number judgment function
{
long int s,y=0;
s=x;
while(s>0)
{
y=y*10+s%10;
s=s/10;
}
if(y==x)
return true; // If it is a palindrome number, it returns 1
else
return false; // If it is not a palindrome number, it returns 0
}
int main()
{
long int number;
scanf("%d",&number);
bool flag = huiwenshu(number);
printf("%d\n",flag);
}
take number Defined as long int Type or long long int Type can be submitted successfully , Defined as int Type will overflow .
Running results :
If it is the palindrome number, it will output 1, If not, it is 0.
边栏推荐
- File operation --i/o
- PHP talent recruitment system development source code recruitment website source code secondary development
- [Jianzhi offer] 61 Shunzi in playing cards
- 网站页面禁止复制内容 JS代码
- 什么是ROM
- C language to get program running time
- Jarvis OJ 远程登录协议
- sqlserver 做cdc 要对数据库性能有什么要求么
- 【剑指 Offer】63. 股票的最大利润
- Apple has abandoned navigationview and used navigationstack and navigationsplitview to implement swiftui navigation
猜你喜欢
The two ways of domestic chip industry chain go hand in hand. ASML really panicked and increased cooperation on a large scale
thinkphp模板的使用
【刷題篇】鹅廠文化衫問題
Fleet tutorial 09 basic introduction to navigationrail (tutorial includes source code)
Browser rendering principle and rearrangement and redrawing
Get ready for the pre-season card game MotoGP ignition champions!
Precision epidemic prevention has a "sharp weapon" | smart core helps digital sentinels escort the resumption of the city
Deep learning plus
【性能测试】jmeter+Grafana+influxdb部署实战
采用药丸屏的iPhone14或引发中国消费者的热烈抢购
随机推荐
The survey shows that the failure rate of traditional data security tools in the face of blackmail software attacks is as high as 60%
Is it safe to open futures accounts online? Will there be more liars online? Doesn't feel very reliable?
[Jianzhi offer] 61 Shunzi in playing cards
How to uninstall MySQL cleanly
Embedded UC (UNIX System Advanced Programming) -1
Writing method of twig array merging
Embedded-c Language-1
【剑指 Offer】61. 扑克牌中的顺子
ECU简介
【机器人坐标系第一讲】
手机开证券账户安全吗?怎么买股票详细步骤
Embedded-c Language-2
【刷題篇】鹅廠文化衫問題
【 brosser le titre 】 chemise culturelle de l'usine d'oies
腾讯音乐上线新产品“曲易买”,提供音乐商用版权授权
【beanshell】数据写入本地多种方法
精准防疫有“利器”| 芯讯通助力数字哨兵护航复市
What else do you not know about new map()
Benji Banas membership pass holders' second quarter reward activities update list
Jarvis OJ Flag