first commit
This commit is contained in:
commit
b5ed398062
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
||||
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "hello"
|
||||
version = "0.1.0"
|
||||
10
Cargo.toml
Normal file
10
Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "hello"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
[[bin]]
|
||||
name = "hello"
|
||||
path = "hello.rs"
|
||||
9
arr.rs
Normal file
9
arr.rs
Normal file
@ -0,0 +1,9 @@
|
||||
fn main() {
|
||||
let arr = [4,5,6,7];
|
||||
let first = arr[0];
|
||||
println!("first {}", first);
|
||||
for i in 0..4 {
|
||||
println!("[{}] - {}", i, arr[i]);
|
||||
}
|
||||
println!("len {}", arr.len());
|
||||
}
|
||||
8
fun.rs
Normal file
8
fun.rs
Normal file
@ -0,0 +1,8 @@
|
||||
fn sqrt(x : f64) -> f64 {
|
||||
return x * x;
|
||||
}
|
||||
fn main() {
|
||||
let inn = 33;
|
||||
let sqrt = sqrt(inn as f64);
|
||||
println!("sqrt of {} is {}", inn, sqrt);
|
||||
}
|
||||
7
hello.rs
Normal file
7
hello.rs
Normal file
@ -0,0 +1,7 @@
|
||||
fn main()
|
||||
{
|
||||
let answer = 43;
|
||||
println!("hello {}", answer);
|
||||
assert_eq!(answer, 42);
|
||||
}
|
||||
|
||||
7
loop2.rs
Normal file
7
loop2.rs
Normal file
@ -0,0 +1,7 @@
|
||||
fn main(){
|
||||
let mut sum = 0.0;
|
||||
for i in 0..4 {
|
||||
sum += i as f64;
|
||||
}
|
||||
println!("sum is {}", sum);
|
||||
}
|
||||
9
loop3.rs
Normal file
9
loop3.rs
Normal file
@ -0,0 +1,9 @@
|
||||
fn main(){
|
||||
for i in 0..4 {
|
||||
if i % 2 == 0 {
|
||||
println!("even {}", i);
|
||||
} else {
|
||||
println!("odd {}", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user