organizado en carpetas
This commit is contained in:
21
curso_tinchicusls/arreglos/src/main.rs
Normal file
21
curso_tinchicusls/arreglos/src/main.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
fn main() {
|
||||
// definimos un array
|
||||
let mi_arreglo_3 = ["Lovecraft", "Poe", "Barker", "King"];
|
||||
// array mutable con 4 enteros
|
||||
let mut _mi_arreglo_2: [i32; 4] = [2, 4, 8, 16];
|
||||
// arreglo vacío tipo string
|
||||
let mut _arreglo_vacio: [&str; 0] = [];
|
||||
// crea el array con cuatro veces el 123
|
||||
let arreglo = [123; 4];
|
||||
// imprimimos para que no den error
|
||||
println!("{} {} {} ", mi_arreglo_3[1], _mi_arreglo_2[2], arreglo[3]);
|
||||
|
||||
let mut mi_arreglo: [&str; 4] = ["", "", "", ""];
|
||||
|
||||
mi_arreglo[0] = "Lovecraft";
|
||||
mi_arreglo[1] = "Poe";
|
||||
mi_arreglo[2] = "Barker";
|
||||
mi_arreglo[3] = "King";
|
||||
|
||||
println!("{}, {}, {}, {}", mi_arreglo[0], mi_arreglo[1], mi_arreglo[2], mi_arreglo[3]);
|
||||
}
|
||||
Reference in New Issue
Block a user