Skip to content

Instantly share code, notes, and snippets.

@iidaatcnt
Created May 20, 2015 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iidaatcnt/3feeb8f7d07f8249702f to your computer and use it in GitHub Desktop.
Save iidaatcnt/3feeb8f7d07f8249702f to your computer and use it in GitHub Desktop.
リストの数字を最大になるように並べる
#!/usr/bin/env xcrun swift
func NumGen(numList: [Int]) -> String {
var strList = [String]()
var str = ""
for var i = 0; i < numList.count; i++ {
strList.append( String(numList[i]) )
}
strList.sort { $1 < $0 }
for var i = 0; i < strList.count; i++ {
str = str + strList[i]
}
return str
}
var numList = [15,12,13,5]
var str:String = ""
str = NumGen(numList)
println(str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment