September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
48
Task/Matrix-transposition/Rust/matrix-transposition.rust
Normal file
48
Task/Matrix-transposition/Rust/matrix-transposition.rust
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
struct Matrix {
|
||||
dat: [[i32; 3]; 3]
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl Matrix {
|
||||
pub fn transpose_m(a: Matrix) -> Matrix
|
||||
{
|
||||
let mut out = Matrix {
|
||||
dat: [[0, 0, 0],
|
||||
[0, 0, 0],
|
||||
[0, 0, 0]
|
||||
]
|
||||
};
|
||||
|
||||
for i in 0..3{
|
||||
for j in 0..3{
|
||||
|
||||
out.dat[i][j] = a.dat[j][i];
|
||||
}
|
||||
}
|
||||
|
||||
out
|
||||
}
|
||||
|
||||
pub fn print(self)
|
||||
{
|
||||
for i in 0..3 {
|
||||
for j in 0..3 {
|
||||
print!("{} ", self.dat[i][j]);
|
||||
}
|
||||
print!("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main()
|
||||
{
|
||||
let a = Matrix {
|
||||
dat: [[1, 2, 3],
|
||||
[4, 5, 6],
|
||||
[7, 8, 9] ]
|
||||
};
|
||||
|
||||
let c = Matrix::transpose_m(a);
|
||||
c.print();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue