当前位置:网站首页>Swift recursively queries the array for the number closest to the specified value
Swift recursively queries the array for the number closest to the specified value
2022-06-25 09:39:00 【A grain of sand-】
The code is relatively simple, so I won't elaborate
var testStr = 0
let arr = [1,4,5,6,9,13,15,16,17,18]
MaxFn(str:4, arr: arr)
func MaxFn(str:Int,arr:Array<Int>) {
var list = [Int]()
for i in 0 ..< arr.count {
let el = arr[i]
if el == str {
testStr = el;
return
}
if el < str && el > testStr {
list.append(el)
testStr = el
}
}
testArr = list
if list.count != 1 {
MaxFn(str: str, arr: list)
}
}
边栏推荐
- Matplotlib simple logistic regression visualization
- [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate
- Vscode attempted to write the procedure to a pipeline that does not exist
- JMeter interface test, associated interface implementation steps (token)
- Cubemx stm32f105rb USB flash drive reading and writing detailed tutorial
- Where is safe for FTSE A50 to open an account
- Atguigu---01-scaffold
- Voiceprint Technology (III): voiceprint recognition technology
- How to "transform" small and micro businesses (I)?
- Arduino bootloader burning summary
猜你喜欢

Matplotlib decision boundary drawing function plot in Matplotlib_ decision_ Boundary and plt Detailed explanation of contour function

Specific usage of sklearn polynomialfeatures

Pytorch_Geometric(PyG)使用DataLoader报错RuntimeError: Sizes of tensors must match except in dimension 0.

vscode试图过程写入管道不存在

可穿戴设备或将会泄露个人隐私

Mapping mode of cache

Etcd教程 — 第四章 Etcd集群安全配置

《JVM》对象内存分配的TLAB机制与G1中的TLAB流程

CYCA 2022少儿形体礼仪初级师资班 深圳总部站圆满结束

Creo makes a mobius belt in the simplest way
随机推荐
35 websites ICER must know
Huipay international permet au commerce électronique transfrontalier de devenir une plate - forme de paiement transfrontalière conforme!
Is it safe to open an account online? Who can I ask?
8、智慧交通项目(1)
【mysql学习笔记21】存储引擎
Is the security account opening risky and safe?
[buuctf.reverse] 117-120
Is it safe to open an account on the compass?
neo4jDesktop(neo4j桌面版)配置自动启动(开机自启)
SQL advanced
使用Navicat对比多环境数据库数据差异和结构差异,以及自动DML和DDL脚本
Cassava tree disease recognition based on vgg16 image classification
Arduino bootloader burning summary
Creo makes a mobius belt in the simplest way
PHP obtains the IP address, and the apache2 server runs without error
[Ruby on rails full stack course] course directory
Voiceprint Technology (I): the past and present life of voiceprint Technology
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate
Match a mobile number from a large number of mobile numbers
8. Intelligent transportation project (1)