当前位置:网站首页>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.
边栏推荐
- Machine learning compilation lesson 2: tensor program abstraction
- Is it safe to open futures accounts online? Will there be more liars online? Doesn't feel very reliable?
- Embedded UC (UNIX System Advanced Programming) -1
- Sentinel-流量防卫兵
- 微信公众号网页授权登录实现起来如此简单
- Embedded-c Language-2
- [61dctf]fm
- 7.Scala类
- Jarvis OJ Flag
- Get ready for the pre-season card game MotoGP ignition champions!
猜你喜欢
Etcd build a highly available etcd cluster
国内首家 EMQ 加入亚马逊云科技「初创加速-全球合作伙伴网络计划」
Jarvis OJ 远程登录协议
Android privacy sandbox developer preview 3: privacy, security and personalized experience
机器学习编译第2讲:张量程序抽象
Keras crash Guide
Games101 notes (I)
项目引入jar从私服Nexus 拉去遇到的一个问题
Solve cmakelist find_ Package cannot find Qt5, ECM cannot be found
File operation --i/o
随机推荐
Android privacy sandbox developer preview 3: privacy, security and personalized experience
WSL2.0安装
【jmeter】jmeter脚本高级写法:接口自动化脚本内全部为变量,参数(参数可jenkins配置),函数等实现完整业务流测试
国产芯片产业链两条路齐头并进,ASML真慌了而大举加大合作力度
启牛商学院股票开户安全吗?靠谱吗?
Embedded-c Language-5
dried food! Semi supervised pre training dialogue model space
Combined use of vant popup+ other components and pit avoidance Guide
【729. 我的日程安排錶 I】
[Jianzhi offer] 63 Maximum profit of stock
Deep dive kotlin synergy (XXI): flow life cycle function
【性能测试】全链路压测
Bs-xx-042 implementation of personnel management system based on SSM
How to uninstall MySQL cleanly
【729. 我的日程安排表 I】
EasyX second lesson
Jarvis OJ Webshell分析
Embedded UC (UNIX System Advanced Programming) -3
Is it safe to open a securities account by mobile phone? Detailed steps of how to buy stocks
Facing new challenges and becoming a better self -- attacking technology er