프로그래밍
rust
mini_project
1.multiplication

과제 1. 구구단 출력

fn print_multiplication(x: u32, y: u32, result: &mut Vec<String>) {
    result.push(format!("{x}*{y}={}", x * y));
    match y {
        9 => (),
        _ => print_multiplication(x, y + 1, result),
    }
}
 
fn print_multiplication_table(x: u32, result: &mut Vec<String>) {
    print_multiplication(x, 1, result);
    match x {
        9 => (),
        _ => print_multiplication_table(x + 1, result),
    }
}
 
fn main() {
    let mut result = vec![];
    print_multiplication_table(1, &mut result);
    println!("{:?}", result)
}