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

边栏推荐
- Benji Banas membership pass holders' second quarter reward activities update list
- Wechat official account web page authorization login is so simple
- High number | summary of calculation methods of volume of rotating body, double integral calculation of volume of rotating body
- File operation --i/o
- Basic introduction to the control of the row component displaying its children in the horizontal array (tutorial includes source code)
- Embedded UC (UNIX System Advanced Programming) -1
- Combined use of vant popup+ other components and pit avoidance Guide
- Embedded UC (UNIX System Advanced Programming) -3
- [729. My Schedule i]
- Keras crash Guide
猜你喜欢
![[729. My schedule I]](/img/e3/32914227d00cf7595ee850e60f2b72.png)
[729. My schedule I]

Deep learning plus
![[Web attack and Defense] WAF detection technology map](/img/7c/60a25764950668ae454b2bc08fe57e.png)
[Web attack and Defense] WAF detection technology map
![[61dctf]fm](/img/22/3e4e3f1679a27d8b905684bb709905.png)
[61dctf]fm

dried food! Semi supervised pre training dialogue model space

Embedded -arm (bare board development) -1

Summary of PHP pseudo protocol of cisp-pte

ECU introduction

Games101 notes (II)

Detailed explanation of use scenarios and functions of polar coordinate sector diagram
随机推荐
Hiengine: comparable to the local cloud native memory database engine
Is it safe for qiniu business school to open a stock account? Is it reliable?
Scratch colorful candied haws Electronic Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
Wsl2.0 installation
Games101 notes (II)
Do sqlserver have any requirements for database performance when doing CDC
Is it safe to open an account for digging wealth stocks? How is it safe to open a stock account?
Excuse me, is the redis syntax used in DMS based on the commands of the redis community version of the cloud database
[Jianzhi offer] 62 The last remaining number in the circle
[brush title] goose factory shirt problem
手机开证券账户安全吗?怎么买股票详细步骤
Timestamp strtotime the day before or after the date
Embedded -arm (bare board development) -2
Keras crash Guide
精准防疫有“利器”| 芯讯通助力数字哨兵护航复市
Wechat official account web page authorization login is so simple
Get ready for the pre-season card game MotoGP ignition champions!
Embedded-c Language-1
2022 年 Q2 加密市场投融资报告:GameFi 成为投资关键词
Can you help me see what the problem is? [ERROR] Could not execute SQL stateme