题解 | #参数解析#
参数解析
https://www.nowcoder.com/practice/668603dc307e4ef4bb07bcd0615ea677
HJ74()
func HJ74() {
while let input = readLine() {
var str = ""
var strs = [String]()
var status = false
for c in input {
if c == "\"" {
status = !status
} else {
if c == " ", status == false {
strs.append(str)
str = ""
} else {
str.append(c)
}
}
}
strs.append(str)
print(strs.count)
for s in strs {
print(s)
}
}
}
func HJ74() {
while let input = readLine() {
var str = ""
var strs = [String]()
var status = false
for c in input {
if c == "\"" {
status = !status
} else {
if c == " ", status == false {
strs.append(str)
str = ""
} else {
str.append(c)
}
}
}
strs.append(str)
print(strs.count)
for s in strs {
print(s)
}
}
}