Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
29
Task/Nth/Swift/nth.swift
Normal file
29
Task/Nth/Swift/nth.swift
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
func addSuffix(n:Int) -> String {
|
||||
if n % 100 / 10 == 1 {
|
||||
return "th"
|
||||
}
|
||||
|
||||
switch n % 10 {
|
||||
case 1:
|
||||
return "st"
|
||||
case 2:
|
||||
return "nd"
|
||||
case 3:
|
||||
return "rd"
|
||||
default:
|
||||
return "th"
|
||||
}
|
||||
}
|
||||
|
||||
for i in 0...25 {
|
||||
print("\(i)\(addSuffix(i)) ")
|
||||
}
|
||||
println()
|
||||
for i in 250...265 {
|
||||
print("\(i)\(addSuffix(i)) ")
|
||||
}
|
||||
println()
|
||||
for i in 1000...1025 {
|
||||
print("\(i)\(addSuffix(i)) ")
|
||||
}
|
||||
println()
|
||||
Loading…
Add table
Add a link
Reference in a new issue