Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Sort-three-variables/Swift/sort-three-variables.swift
Normal file
24
Task/Sort-three-variables/Swift/sort-three-variables.swift
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
func varSort<T: Comparable>(_ x: inout T, _ y: inout T, _ z: inout T) {
|
||||
let res = [x, y, z].sorted()
|
||||
|
||||
x = res[0]
|
||||
y = res[1]
|
||||
z = res[2]
|
||||
}
|
||||
|
||||
var x = "lions, tigers, and"
|
||||
var y = "bears, oh my!"
|
||||
var z = "(from the \"Wizard of OZ\")"
|
||||
|
||||
print("Before:")
|
||||
print("x = \(x)")
|
||||
print("y = \(y)")
|
||||
print("z = \(z)")
|
||||
print()
|
||||
|
||||
varSort(&x, &y, &z)
|
||||
|
||||
print("After:")
|
||||
print("x = \(x)")
|
||||
print("y = \(y)")
|
||||
print("z = \(z)")
|
||||
Loading…
Add table
Add a link
Reference in a new issue