当前位置:网站首页>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_dailyWorkhttps://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
边栏推荐
- [IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games
- uTools
- Electronic Society C language level 1 32, calculate the power of 2
- ES6 new method of string
- Feature extraction and detection 16 brisk feature detection and matching
- Android: how can golden nine and silver ten squeeze into the first-line big factories from small and medium-sized enterprises? The depth of interview questions in large factories
- 城市选择器组件实现原理
- 遊戲思考15:全區全服和分區分服的思考
- KS006基于SSM实现学生成绩管理系统
- Matlab uses resample to complete resampling
猜你喜欢
Six lessons to be learned for the successful implementation of edge coding
GL Studio 5 installation and experience
Learn C language from scratch day 025 (maze)
[image enhancement] vascular image enhancement based on frangi filter with matlab code
Three core problems of concurrent programming
Basic concepts of machine learning
SAP ui5 beginner tutorial 20 - explanation of expression binding usage of SAP ui5
如何远程、在线调试app?
MySQL application day02
学习笔记3--高精度地图关键技术(上)
随机推荐
The smart Park "ZhongGuanCun No.1" subverts your understanding of the park
开发那些事儿:如何利用Go单例模式保障流媒体高并发的安全性?
matlab 使用 audiorecorder、recordblocking录制声音,play 播放声音,audiowrite 保存声音
Ubuntu20.04 PostgreSQL 14 installation configuration record
学习笔记25--多传感器前融合技术
Edge computing accelerates live video scenes: clearer, smoother, and more real-time
Makefile simple induction
只是以消费互联网的方式和方法来落地和实践产业互联网,并不能够带来长久的发展
uTools
Exclusive delivery of secret script move disassembly (the first time)
浅浅了解Servlet
Develop those things: how to use go singleton mode to ensure the security of high concurrency of streaming media?
Design and implementation of radio energy transmission system
Learn basic K-line diagram knowledge in three minutes
Learn about servlets
This is the form of the K-line diagram (pithy formula)
Ubuntu20.04 PostgreSQL 14 installation configuration record
Liteos learning - first knowledge of development environment
ECS project deployment
[disease detection] realize lung cancer detection system based on BP neural network, including GUI interface