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

边栏推荐
- What is ROM
- Allusions of King Xuan of Qi Dynasty
- 干货!半监督预训练对话模型 SPACE
- 国产芯片产业链两条路齐头并进,ASML真慌了而大举加大合作力度
- Is it safe for qiniu business school to open a stock account? Is it reliable?
- [brush questions] effective Sudoku
- Embedded-c Language-4
- PHP talent recruitment system development source code recruitment website source code secondary development
- PHP人才招聘系统开发 源代码 招聘网站源码二次开发
- 微信公众号网页授权登录实现起来如此简单
猜你喜欢

Detailed explanation of use scenarios and functions of polar coordinate sector diagram

Application of threshold homomorphic encryption in privacy Computing: Interpretation

Learnopongl notes (II) - Lighting

American chips are no longer proud, and Chinese chips have successfully won the first place in emerging fields
![[61dctf]fm](/img/22/3e4e3f1679a27d8b905684bb709905.png)
[61dctf]fm

thinkphp模板的使用

干货!半监督预训练对话模型 SPACE

Browser rendering principle and rearrangement and redrawing

ECU introduction

File operation --i/o
随机推荐
飞桨EasyDL实操范例:工业零件划痕自动识别
中国广电正式推出5G服务,中国移动赶紧推出免费服务挽留用户
Jarvis OJ simple network management protocol
Embedded -arm (bare board development) -2
The third lesson of EasyX learning
How to uninstall MySQL cleanly
[first lecture on robot coordinate system]
Google Earth engine (GEE) -- a brief introduction to kernel kernel functions and gray level co-occurrence matrix
启牛商学院股票开户安全吗?靠谱吗?
美国芯片傲不起来了,中国芯片成功在新兴领域夺得第一名
Embedded-c Language-2
时间戳strtotime前一天或后一天的日期
Learnopongl notes (II) - Lighting
Is it safe to open a securities account by mobile phone? Detailed steps of how to buy stocks
PHP strict mode
项目引入jar从私服Nexus 拉去遇到的一个问题
sqlserver 做cdc 要对数据库性能有什么要求么
Jarvis OJ shell traffic analysis
C# TCP如何限制单个客户端的访问流量
File operation --i/o