当前位置:网站首页>C language practice (IX)
C language practice (IX)
2022-06-11 02:04:00 【It's Luoluo】
List of articles
1. Given an array of integers nums And an integer target value target, Please find... In the array And is the target value target the Two Integers , And return their array subscripts
Method 1 : Two level loop traversal
int* twoSum(int* nums, int numsSize, int target, int* returnSize){
int i,j;
for(i=0;i<numsSize;i++){
for(j=i+1;j<numsSize;j++){
if(nums[i] + nums[j] == target){
// find
int *new = (int *)malloc(2*sizeof(int));
new[0]=i;
new[j]=j;
*returnSize = 2;
return new;
}
}
}
// There is no answer
*returnSize = 0;
return NULL;
}
2. 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 .
bool isPalindrome(int x){
if(x<0 || x%10 ==0 && x!=0) // with '-', Or ending with 0
return false;
else{
int revertNumber = 0;
while(x>revertNumber){
revertNumber = revertNumber*10+x%10;
x /= 10;
}
return x==revertNumber || x==revertNumber/10;
}
}
边栏推荐
- 小包子关于分红的思考
- Task01: be familiar with the basic process of news recommendation system
- Task02: linked list
- 【MATLAB】图像变换(傅里叶变换、离散余弦变换)
- 【MATLAB】MATLAB图像处理基本操作
- Exj shaped children will be satisfied with mbtxe due to disconnection
- [leetcode] balanced binary tree
- 【错误记录】Android 应用安全检测漏洞修复 ( StrandHogg 漏洞 | 设置 Activity 组件 android:taskAffinity=““ )
- [leetcode] construct a binary tree by traversing the sequence from front to middle (continuous optimization)
- Xpath注入
猜你喜欢

2021-02-27image processing of MATLAB

CLIP论文详解

Dinner a bang's Craft

Xpath注入
![[traffic sign recognition] Based on Matlab GUI YCbCr feature extraction +bp neural network traffic sign recognition [including Matlab source code 1869]](/img/66/3f7134298e7e9a7fbf9b0c99dafb2a.jpg)
[traffic sign recognition] Based on Matlab GUI YCbCr feature extraction +bp neural network traffic sign recognition [including Matlab source code 1869]
![[leetcode] restore binary search tree](/img/92/14c4d670f318f93297040241a61c41.jpg)
[leetcode] restore binary search tree

爱思唯尔---Elseviewer---预印本在线发表通知
![[winning] Title A of the 9th Teddy Cup Challenge](/img/86/8445c4ac47d4fa7630544984fa0c58.jpg)
[winning] Title A of the 9th Teddy Cup Challenge

Project sorting of Online Exercise System Based on gin and Gorm

Metersphere tutorial: how to assert when the returned result of the interface is null
随机推荐
[linked list] find the midpoint of the linked list and deepen the understanding and Application
[Qt] Erreur: qapplication: No such file or directory Solution
Task07: double pointer
Task02: basic use of database (MySQL)
爱思唯尔---Elseviewer---预印本在线发表通知
[matlab] image segmentation
Kubernetes binary installation (v1.20.15) (VII) plug a work node
【云原生 | Kubernetes篇】Ingress案例实战
[leetcode] different binary search trees (recursion - recursion + memory search optimization - dynamic programming)
Some records of China open SSL compilation
Database overview
2021-3-1matlas MNIST database training for CNN writing
Treatment of small fish
[leetcode] path sum II (first glimpse recursion + backtracking)
Fallible point--
薪的测试开发程序员们,你为何要走?和产品相互残杀到天昏地暗......
逻辑漏洞 / 业务漏洞
Task02: linked list
小鱼儿的处理
[matlab] image transform (Fourier transform, discrete cosine transform)