当前位置:网站首页>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.
边栏推荐
- Embedded UC (UNIX System Advanced Programming) -3
- How to install MySQL
- Do sqlserver have any requirements for database performance when doing CDC
- Jarvis OJ Webshell分析
- composer安装报错:No composer.lock file present.
- Combined use of vant popup+ other components and pit avoidance Guide
- Basic introduction to the control of the row component displaying its children in the horizontal array (tutorial includes source code)
- thinkphp模板的使用
- Jarvis OJ webshell analysis
- How to uninstall MySQL cleanly
猜你喜欢
Etcd build a highly available etcd cluster
NPM installation
Embedded-c Language-1
国内首家 EMQ 加入亚马逊云科技「初创加速-全球合作伙伴网络计划」
调查显示传统数据安全工具面对勒索软件攻击的失败率高达 60%
7.Scala类
Error in composer installation: no composer lock file present.
Learnopongl notes (I)
PHP talent recruitment system development source code recruitment website source code secondary development
Solution of vant tabbar blocking content
随机推荐
美国芯片傲不起来了,中国芯片成功在新兴领域夺得第一名
[first lecture on robot coordinate system]
【性能测试】jmeter+Grafana+influxdb部署实战
Jarvis OJ shell traffic analysis
tf. sequence_ Mask function explanation case
American chips are no longer proud, and Chinese chips have successfully won the first place in emerging fields
【微信小程序】一文读懂小程序的生命周期和路由跳转
Jarvis OJ Webshell分析
[brush questions] effective Sudoku
飞桨EasyDL实操范例:工业零件划痕自动识别
sqlserver 做cdc 要对数据库性能有什么要求么
Use JDBC technology and MySQL database management system to realize the function of course management, including adding, modifying, querying and deleting course information.
Detailed explanation of use scenarios and functions of polar coordinate sector diagram
Games101 notes (III)
Embedded UC (UNIX System Advanced Programming) -2
What is ROM
Can you help me see what the problem is? [ERROR] Could not execute SQL stateme
Writing method of twig array merging
【剑指 Offer】61. 扑克牌中的顺子
Jarvis OJ 远程登录协议