当前位置:网站首页>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.

边栏推荐
- Apple has abandoned navigationview and used navigationstack and navigationsplitview to implement swiftui navigation
- tf. sequence_ Mask function explanation case
- Jarvis OJ shell traffic analysis
- Embedded-c language-6
- [Jianzhi offer] 63 Maximum profit of stock
- Google Earth engine (GEE) -- a brief introduction to kernel kernel functions and gray level co-occurrence matrix
- Allusions of King Xuan of Qi Dynasty
- The survey shows that the failure rate of traditional data security tools in the face of blackmail software attacks is as high as 60%
- 【729. 我的日程安排錶 I】
- 国产芯片产业链两条路齐头并进,ASML真慌了而大举加大合作力度
猜你喜欢
![[61dctf]fm](/img/22/3e4e3f1679a27d8b905684bb709905.png)
[61dctf]fm

Jarvis OJ 远程登录协议

中国广电正式推出5G服务,中国移动赶紧推出免费服务挽留用户

SQL injection of cisp-pte (Application of secondary injection)

Fleet tutorial 09 basic introduction to navigationrail (tutorial includes source code)

Embedded UC (UNIX System Advanced Programming) -3

thinkphp3.2.3

Solve cmakelist find_ Package cannot find Qt5, ECM cannot be found

精准防疫有“利器”| 芯讯通助力数字哨兵护航复市

Embedded UC (UNIX System Advanced Programming) -2
随机推荐
Get ready for the pre-season card game MotoGP ignition champions!
挖财股票开户安全吗?怎么开股票账户是安全?
Games101 notes (II)
ECU简介
Jarvis OJ 远程登录协议
Embedded-c Language-5
[Web attack and Defense] WAF detection technology map
Benji Banas membership pass holders' second quarter reward activities update list
Embedded -arm (bare board development) -1
Jarvis OJ Webshell分析
China Radio and television officially launched 5g services, and China Mobile quickly launched free services to retain users
ECU introduction
[Jianzhi offer] 62 The last remaining number in the circle
Practical example of propeller easydl: automatic scratch recognition of industrial parts
[Jianzhi offer] 61 Shunzi in playing cards
sqlserver 做cdc 要对数据库性能有什么要求么
thinkphp3.2.3
项目引入jar从私服Nexus 拉去遇到的一个问题
File operation --i/o
采用药丸屏的iPhone14或引发中国消费者的热烈抢购