Rust 言語処理 100本ノック
// 言語処理 100本ノック http://www.cl.ecei.tohoku.ac.jp/nlp100/#ch1
fn main() {
knock_3("パトカー", "タクシー");
knock_2();
knock_1();
}
fn knock_3(s1: &str, s2: &str){
println!("{}", s1);
println!("{}", s2);
}
fn knock_2(){
let s = "パタトクカシーー";
let mut ss1 = "".to_string();
let mut ss2 = "".to_string();
for (i, v) in s.chars().enumerate() {
match i {
0 => ss1 = ss1 + &v.to_string(),
1 => ss2 = ss2 + &v.to_string(),
2 => ss1 = ss1 + &v.to_string(),
3 => ss2 = ss2 + &v.to_string(),
4 => ss1 = ss1 + &v.to_string(),
5 => ss2 = ss2 + &v.to_string(),
6 => ss1 = ss1 + &v.to_string(),
7 => ss2 = ss2 + &v.to_string(),
_ => ss1 = ss1 + &v.to_string()
}
}
println!("{}", ss1);
println!("{}", ss2);
}
fn knock_1(){
let s= "stressed";
let mut ss: String = "".to_string();
for r in s.chars().rev() {
ss = ss + &r.to_string();
}
println!("{}", ss);
}