nombre y arreglos2
This commit is contained in:
@@ -20,3 +20,5 @@
|
|||||||
- https://tinchicus.com/2022/06/27/rust-closures/ (cierre)
|
- https://tinchicus.com/2022/06/27/rust-closures/ (cierre)
|
||||||
- https://tinchicus.com/2022/06/28/rust-iteradores/ (iter)
|
- https://tinchicus.com/2022/06/28/rust-iteradores/ (iter)
|
||||||
- https://tinchicus.com/2022/06/29/rust-el-parametro-_/ (bucles2)
|
- https://tinchicus.com/2022/06/29/rust-el-parametro-_/ (bucles2)
|
||||||
|
- https://tinchicus.com/2022/06/30/rust-loop-27/ (arreglos2)
|
||||||
|
- https://tinchicus.com/2022/07/01/rust-loop-labels/ (nombre)
|
||||||
|
|||||||
8
arreglos2/Cargo.toml
Normal file
8
arreglos2/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "arreglos2"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
12
arreglos2/src/main.rs
Normal file
12
arreglos2/src/main.rs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
fn main() {
|
||||||
|
let mi_arreglo = ["Lovecraft", "Poe", "Barker", "King"];
|
||||||
|
let mut i = 0;
|
||||||
|
|
||||||
|
loop {
|
||||||
|
if i >= mi_arreglo.len() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
println!("{}", mi_arreglo[i]);
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
8
nombre/Cargo.toml
Normal file
8
nombre/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[package]
|
||||||
|
name = "nombre"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
13
nombre/src/main.rs
Normal file
13
nombre/src/main.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
fn main() {
|
||||||
|
'bucle_externo: for x in 0..10 {
|
||||||
|
'bucle_interno: for y in 0..10 {
|
||||||
|
if x % 2 == 0 {
|
||||||
|
continue 'bucle_externo;
|
||||||
|
}
|
||||||
|
if y % 2 != 0 {
|
||||||
|
continue 'bucle_interno;
|
||||||
|
}
|
||||||
|
println!("X: {}, Y: {}", x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ fn primera_palabra(s: &String) -> usize {
|
|||||||
let b = s.as_bytes();
|
let b = s.as_bytes();
|
||||||
for (i, &item) in b.iter().enumerate() {
|
for (i, &item) in b.iter().enumerate() {
|
||||||
if item == b' ' {
|
if item == b' ' {
|
||||||
return i
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.len()
|
s.len()
|
||||||
@@ -12,5 +12,5 @@ fn main() {
|
|||||||
let s = String::from("Hola Mundo Cruel");
|
let s = String::from("Hola Mundo Cruel");
|
||||||
let pos = primera_palabra(&s);
|
let pos = primera_palabra(&s);
|
||||||
let palabra = &s[0..pos];
|
let palabra = &s[0..pos];
|
||||||
println!("{}",palabra)
|
println!("{}", palabra);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user