// Transpose a matrix
fn matrix_transpose(m: Vec<Vec<i32>>) -> Vec<Vec<i32>> {
let mut t = vec![Vec::with_capacity(m.len()); m[0].len()];
for r in m {
for i in 0..r.len() {
t[i].push(r[i]);
}
}
t
}
fn main() {
let m = vec![vec![1, 2, 3], vec![4, 5, 6], vec![7, 8, 9]];
println!("Matrix:
{:?}", m);
let t = matrix_transpose(m);
println!("Transpose:
{:?}", t);
}