题解 | #字符串最后一个单词的长度#
字符串最后一个单词的长度
http://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
use std::io;
fn main() { // loop { let mut s = String::new(); let a = io::stdin() .read_line(&mut s) .expect("Fail to read this line!");
let mut c: u32 = 0;
for _si in s.split_whitespace() {
c = c + 1;
}
let mut d: u32 = 0;
for si in s.split_whitespace() {
d = d + 1;
if d == c {
println!("{}", si.len());
}
}
// if a == 1 { // break; // } else { // continue; // } // } }