Swift题解:

while let str = readLine(), let n = Int(str) {
    let binary = String.init(n, radix: 2, uppercase: false)
    let array = binary.components(separatedBy: "0").sorted { s1, s2 in
        return s1.count < s2.count
    }
    let count = array.last?.count ?? 0
    print(count)
}