当前位置:网站首页>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.
边栏推荐
- 【 brosser le titre 】 chemise culturelle de l'usine d'oies
- Excuse me, is the redis syntax used in DMS based on the commands of the redis community version of the cloud database
- [first lecture on robot coordinate system]
- Fleet tutorial 09 basic introduction to navigationrail (tutorial includes source code)
- C how TCP restricts the access traffic of a single client
- C language to get program running time
- 微信公众号网页授权登录实现起来如此简单
- 调查显示传统数据安全工具面对勒索软件攻击的失败率高达 60%
- Browser rendering principle and rearrangement and redrawing
- Cs231n notes (bottom) - applicable to 0 Foundation
猜你喜欢
阈值同态加密在隐私计算中的应用:解读
[729. My Schedule i]
Jarvis OJ Flag
thinkphp模板的使用
Benji Banas membership pass holders' second quarter reward activities update list
Copy mode DMA
Application of threshold homomorphic encryption in privacy Computing: Interpretation
Embedded-c Language-1
项目引入jar从私服Nexus 拉去遇到的一个问题
Fleet tutorial 09 basic introduction to navigationrail (tutorial includes source code)
随机推荐
American chips are no longer proud, and Chinese chips have successfully won the first place in emerging fields
Facing new challenges and becoming a better self -- attacking technology er
PHP talent recruitment system development source code recruitment website source code secondary development
tf. sequence_ Mask function explanation case
Jarvis OJ Webshell分析
Is it safe to open futures accounts online? Will there be more liars online? Doesn't feel very reliable?
Fleet tutorial 09 basic introduction to navigationrail (tutorial includes source code)
Basic introduction to the control of the row component displaying its children in the horizontal array (tutorial includes source code)
Embedded -arm (bare board development) -1
手机开证券账户安全吗?怎么买股票详细步骤
[brush questions] effective Sudoku
Error in composer installation: no composer lock file present.
【机器人坐标系第一讲】
How does the outer disk futures platform distinguish formal security?
Jarvis OJ shell traffic analysis
中国广电正式推出5G服务,中国移动赶紧推出免费服务挽留用户
飞桨EasyDL实操范例:工业零件划痕自动识别
Do sqlserver have any requirements for database performance when doing CDC
网上办理期货开户安全吗?网上会不会骗子比较多?感觉不太靠谱?
启牛商学院股票开户安全吗?靠谱吗?