first commit

This commit is contained in:
Alter 2026-09-09 14:04:38 +02:00
commit b5ed398062
17 changed files with 77 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

7
Cargo.lock generated Normal file
View 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
View File

@ -0,0 +1,10 @@
[package]
name = "hello"
version = "0.1.0"
edition = "2024"
[dependencies]
[[bin]]
name = "hello"
path = "hello.rs"

BIN
arr Executable file

Binary file not shown.

9
arr.rs Normal file
View 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());
}

BIN
fun Executable file

Binary file not shown.

8
fun.rs Normal file
View 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);
}

BIN
hello Executable file

Binary file not shown.

7
hello.rs Normal file
View File

@ -0,0 +1,7 @@
fn main()
{
let answer = 43;
println!("hello {}", answer);
assert_eq!(answer, 42);
}

BIN
loop Executable file

Binary file not shown.

5
loop.rs Normal file
View File

@ -0,0 +1,5 @@
fn main(){
for i in 0..4 {
println!("-> {}", i);
}
}

BIN
loop2 Executable file

Binary file not shown.

7
loop2.rs Normal file
View 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);
}

BIN
loop3 Executable file

Binary file not shown.

9
loop3.rs Normal file
View File

@ -0,0 +1,9 @@
fn main(){
for i in 0..4 {
if i % 2 == 0 {
println!("even {}", i);
} else {
println!("odd {}", i);
}
}
}

BIN
slice Executable file

Binary file not shown.

14
slice.rs Normal file
View File

@ -0,0 +1,14 @@
fn sum(arr: &[i32]) -> i32 {
let mut sum = 0;
for i in 0..arr.len() {
sum += arr[i];
}
sum
}
fn main() {
let arr = [4, 6, 8, 9, 11];
let res = sum(&arr);
println!("sum is {}", res);
println!("arr is {:?}", arr);
}