ez_input 0.1.0

make rust input easy!
Documentation

// examples/cp_scenario.rs
use ez_input::{Scanner, ScannerExt};

fn main() {
    let mut sc = Scanner::stdin();

    // 读取测试用例数
    let t: i32 = sc.next();

    for case in 1..=t {
        let n: usize = sc.next();
        let m: usize = sc.next();

        // 读取数组
        let arr: Vec<i32> = sc.next_vec(n);

        // 读取矩阵
        let matrix: Vec<Vec<i32>> = (0..n)
            .map(|_| (0..m).map(|_| sc.next()).collect())
            .collect();

        // 使用迭代器
        let sum: i32 = sc.iter::<i32>().take(m).sum();

        println!("Case #{}: {} {} {}", case, arr[0], matrix[0][0], sum);
    }
}