当前位置:网站首页>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
边栏推荐
- Six lessons to be learned for the successful implementation of edge coding
- The role of artificial intelligence in network security
- Basic concepts of machine learning
- 如何远程、在线调试app?
- 学习笔记2--高精度地图定义及价值
- CTF daily question day45 sensor
- TSINGSEE青犀平台如何实现同一节点同时播放多个视频?
- 卷积神经网络(包含代码与相应图解)
- uTools
- error: . repo/manifests/: contains uncommitted changes
猜你喜欢
Day 13 of hcip (relevant contents of BGP agreement)
Four basic strategies for migrating cloud computing workloads
[IVX junior engineer training course 10 papers to get certificates] 03 events and guessing numbers games
Implementation of Weibo system based on SSM
Ks006 student achievement management system based on SSM
Introduction to ffmpeg Lib
This is the form of the K-line diagram (pithy formula)
Learn basic K-line diagram knowledge in three minutes
Learn C language from scratch day 025 (maze)
6-3漏洞利用-SSH环境搭建
随机推荐
Feature extraction and detection 16 brisk feature detection and matching
1218 square or round
Docker installing Oracle_ 11g
uTools
Makefile simple induction
Memorabilia of domestic database in June 2022
浅浅了解Servlet
Load and domcontentloaded in JS
微信小程序中使用tabBar
Appium inspector can directly locate the WebView page. Does anyone know the principle
Laravel artisan 常用命令
Six lessons to be learned for the successful implementation of edge coding
10 minutes to get started quickly composition API (setup syntax sugar writing method)
Implementation principle of city selector component
Convolutional neural network (including code and corresponding diagram)
Since I understand the idea of dynamic planning, I have opened the door to a new world
机器学习基本概念
What is AQS and its principle
遊戲思考15:全區全服和分區分服的思考
Using tabbar in wechat applet