style: use string interpolation in print

This commit is contained in:
nuomi1 2023-01-08 20:54:40 +08:00
parent 3b52df2a8f
commit f3e9c2cf89
No known key found for this signature in database
GPG Key ID: E410D5FF602FBF25
3 changed files with 16 additions and 16 deletions

View File

@ -137,36 +137,36 @@ enum TimeComplexity {
static func main() {
// n
let n = 8
print("输入数据大小 n =", n)
print("输入数据大小 n = \(n)")
var count = constant(n: n)
print("常数阶的计算操作数量 =", count)
print("常数阶的计算操作数量 = \(count)")
count = linear(n: n)
print("线性阶的计算操作数量 =", count)
print("线性阶的计算操作数量 = \(count)")
count = arrayTraversal(nums: Array(repeating: 0, count: n))
print("线性阶(遍历数组)的计算操作数量 =", count)
print("线性阶(遍历数组)的计算操作数量 = \(count)")
count = quadratic(n: n)
print("平方阶的计算操作数量 =", count)
print("平方阶的计算操作数量 = \(count)")
var nums = Array(sequence(first: n, next: { $0 > 0 ? $0 - 1 : nil })) // [n,n-1,...,2,1]
count = bubbleSort(nums: &nums)
print("平方阶(冒泡排序)的计算操作数量 =", count)
print("平方阶(冒泡排序)的计算操作数量 = \(count)")
count = exponential(n: n)
print("指数阶(循环实现)的计算操作数量 =", count)
print("指数阶(循环实现)的计算操作数量 = \(count)")
count = expRecur(n: n)
print("指数阶(递归实现)的计算操作数量 =", count)
print("指数阶(递归实现)的计算操作数量 = \(count)")
count = logarithmic(n: n)
print("对数阶(循环实现)的计算操作数量 =", count)
print("对数阶(循环实现)的计算操作数量 = \(count)")
count = logRecur(n: n)
print("对数阶(递归实现)的计算操作数量 =", count)
print("对数阶(递归实现)的计算操作数量 = \(count)")
count = linearLogRecur(n: Double(n))
print("线性对数阶(递归实现)的计算操作数量 =", count)
print("线性对数阶(递归实现)的计算操作数量 = \(count)")
count = factorialRecur(n: n)
print("阶乘阶(递归实现)的计算操作数量 =", count)
print("阶乘阶(递归实现)的计算操作数量 = \(count)")
}
}

View File

@ -31,8 +31,8 @@ enum WorstBestTimeComplexity {
let n = 100
let nums = randomNumbers(n: n)
let index = findOne(nums: nums)
print("数组 [ 1, 2, ..., n ] 被打乱后 =", nums)
print("数字 1 的索引为", index)
print("数组 [ 1, 2, ..., n ] 被打乱后 = \(nums)")
print("数字 1 的索引为 \(index)")
}
}
}

View File

@ -2683,8 +2683,8 @@ $$
let n = 100
let nums = randomNumbers(n: n)
let index = findOne(nums: nums)
print("数组 [ 1, 2, ..., n ] 被打乱后 =", nums)
print("数字 1 的索引为", index)
print("数组 [ 1, 2, ..., n ] 被打乱后 = \(nums)")
print("数字 1 的索引为 \(index)")
}
}
```