当前位置:网站首页>Number of palindromes in C language (leetcode)
Number of palindromes in C language (leetcode)
2022-07-02 01:40:00 【Frank. Ren】
Give you an integer x , If x Is a palindrome integer , return true ; otherwise , return false .
Palindrome number refers to positive order ( From left to right ) Reverse order ( From right to left ) Read all the same integers .
for example ,121 It's palindrome. , and 123 No .


Part of the code is as follows :
int isPalindrome(int x) {
char a[100];
sprintf(a, "%d", x);// Integer x, Convert to string a in
int left = 0, right = 0;// Judge inward from both sides of the array , Define two left and right indexes
right = strlen(a) - 1;// Array from 0 Start , Minus one digit
for (right, left; right > left; right--, left++)
// You judge inward from the head and tail , Index of the head ++, Tail index --, If the index of the header is larger than the index of the tail , Explain that the judgment is complete
{
if (a[right] != a[left])
{
return 0;
}
}
return 1;
}The complete code has been put into github:
GitHub - frankRenlf/c_dailyWork
https://github.com/frankRenlf/c_dailyWork.git
If you have questions, you can point out in the comments , If you think it's OK, give me praise and attention
You can also focus on this series , There will be updates later , And other code output
边栏推荐
- Penser au jeu 15: penser au service complet et au sous - service
- D discard the virtual recovery method
- 基于SSM实现微博系统
- 【图像增强】基于Frangi滤波器实现血管图像增强附matlab代码
- 自动浏览拼多多商品
- Learning note 24 - multi sensor post fusion technology
- Edge extraction edges based on Halcon learning_ image. Hdev routine
- [Obsidian] wechat is sent to Obsidian using remotely save S3 compatibility
- GL Studio 5 安装与体验
- 机器学习基本概念
猜你喜欢
![[IVX junior engineer training course 10 papers to get certificates] 09 chat room production](/img/a8/25215e74162b7ab3f29df65681932b.jpg)
[IVX junior engineer training course 10 papers to get certificates] 09 chat room production

Matlab uses audiorecorder and recordblocking to record sound, play to play sound, and audiobook to save sound

matlab 使用 audioread 、 sound 读取和播放 wav 文件
![[image enhancement] vascular image enhancement based on frangi filter with matlab code](/img/b3/b4164fb7db8645f470180e352b5717.png)
[image enhancement] vascular image enhancement based on frangi filter with matlab code
![[IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production](/img/b7/aecb815ca9545981563a1e16cfa19e.jpg)
[IVX junior engineer training course 10 papers] 02 numerical binding and adaptive website production

学习笔记3--高精度地图关键技术(上)

MPLS experiment operation

6-2 vulnerability exploitation - inevitable problems of FTP

New news, Wuhan Yangluo international port, filled with black technology, refreshes your understanding of the port

Réseau neuronal convolutif (y compris le Code et l'illustration correspondante)
随机推荐
Using tabbar in wechat applet
2022年6月国产数据库大事记
1217 supermarket coin processor
Raspberry pie 4B learning notes - IO communication (1-wire)
学习笔记25--多传感器前融合技术
[image enhancement] vascular image enhancement based on frangi filter with matlab code
Should enterprises choose server free computing?
Self drawing of menu items and CListBox items
Edge extraction edges based on Halcon learning_ image. Hdev routine
遊戲思考15:全區全服和分區分服的思考
大学的知识是否学而无用、过时?
What are the skills of spot gold analysis?
[Chongqing Guangdong education] Tianshui Normal University universe exploration reference
Four basic strategies for migrating cloud computing workloads
Matlab uses audioread and sound to read and play WAV files
Matlab uses resample to complete resampling
error: . repo/manifests/: contains uncommitted changes
微信小程序中使用tabBar
Pyldavis installation and use | attributeerror: module 'pyldavis' has no attribute' gensim '| visual results are exported as separate web pages
6-3漏洞利用-SSH环境搭建