240 發(fā)簡信
IP屬地:湖北
  • 基于Swift4,最后一題字符串處理的題目可以通過字符串索引的方式來做:
    func reversedByWord(sentence: String) -> String {
    var lastWordIndex = sentence.startIndex
    var copySentence = sentence
    var ans = ""
    copySentence.append(" ")
    for i in copySentence.indices {
    if copySentence[i] == " " {
    let subString = String(copySentence[lastWordIndex..<i].reversed())
    lastWordIndex = copySentence.index(after: i)
    ans += subString + " "
    }
    }
    ans.removeLast()
    return ans
    }

    reversedByWord(sentence: "The quick brown fox jumps over the lazy dog")

    func reversedSantence(sentence: String) -> String {
    let ans = String(reversedByWord(sentence: sentence).reversed())
    return ans
    }
    reversedSantence(sentence: "the sky is blue")

  • 120
    Swift 算法實(shí)戰(zhàn)之路:數(shù)組壁畸,字符串,集合茅茂,與字典

    上次講解了基本的語法和一些Swift的小技巧捏萍。這期我們來看幾個(gè)最基本的數(shù)據(jù)結(jié)構(gòu):數(shù)組,字符串空闲,集合和字典令杈。 數(shù)組 數(shù)組是最基本的數(shù)據(jù)結(jié)構(gòu)。Swift中改變了以前Objecti...

亚洲A日韩AV无卡,小受高潮白浆痉挛av免费观看,成人AV无码久久久久不卡网站,国产AV日韩精品