当前位置:网站首页>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.
边栏推荐
- Twig数组合并的写法
- 【机器人坐标系第一讲】
- 时间戳strtotime前一天或后一天的日期
- Embedded-c Language-3
- 【testlink】TestLink1.9.18常见问题解决方法
- American chips are no longer proud, and Chinese chips have successfully won the first place in emerging fields
- 国内首家 EMQ 加入亚马逊云科技「初创加速-全球合作伙伴网络计划」
- Jarvis OJ Webshell分析
- tf. sequence_ Mask function explanation case
- What is ROM
猜你喜欢
腾讯音乐上线新产品“曲易买”,提供音乐商用版权授权
If you can't afford a real cat, you can use code to suck cats -unity particles to draw cats
Deep learning plus
Benji Banas membership pass holders' second quarter reward activities update list
浏览器渲染原理以及重排与重绘
【性能测试】jmeter+Grafana+influxdb部署实战
【机器人坐标系第一讲】
【刷題篇】鹅廠文化衫問題
Embedded UC (UNIX System Advanced Programming) -2
Get ready for the pre-season card game MotoGP ignition champions!
随机推荐
[61dctf]fm
Embedded-c Language-3
微信公众号网页授权登录实现起来如此简单
Embedded UC (UNIX System Advanced Programming) -2
easyNmon使用汇总
Embedded-c language-6
Etcd build a highly available etcd cluster
Scratch colorful candied haws Electronic Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
Practical example of propeller easydl: automatic scratch recognition of industrial parts
npm安装
[Jianzhi offer] 61 Shunzi in playing cards
High number | summary of calculation methods of volume of rotating body, double integral calculation of volume of rotating body
ECU简介
时间戳strtotime前一天或后一天的日期
高数 | 旋转体体积计算方法汇总、二重积分计算旋转体体积
C# TCP如何设置心跳数据包,才显得优雅呢?
Copy mode DMA
麻烦问下,DMS中使用Redis语法是以云数据库Redis社区版的命令为参考的嘛
Is it safe to open a securities account by mobile phone? Detailed steps of how to buy stocks
Timestamp strtotime the day before or after the date