Created
April 11, 2024 05:49
-
-
Save jonathanwork/8e0bca80588971f6fd124e00abb15e82 to your computer and use it in GitHub Desktop.
simple rust programs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn vector() -> Vec<i16> { | |
let mut v : Vec<i16> = | |
Vec::<i16>::new() ; | |
v.push(10i16); | |
v.push(20i16); | |
v | |
} | |
fn many() { | |
let mut sieve = [true; 1000] ; | |
for i in 2..100 { | |
if sieve[i] { | |
let mut j = i* i ; | |
while j < 1000 { | |
sieve[j] = false; | |
j += i | |
} | |
} | |
} | |
println!("{:?}" , sieve) | |
} | |
fn main() { | |
println!("Hello, world!"); | |
let run = | |
vector(); | |
println!("{run:#?}" ); | |
many() ; | |
let lazy_caterer: [u32; 6] = [1, 2,3, 4, 5, 6 ] ; | |
let tax = ["animalia" , "Arthropoda" , "Insecta"]; | |
println!("{}", lazy_caterer[3] ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment