lr1 rust

parent 9fea1004
...@@ -7,5 +7,6 @@ fn main() ...@@ -7,5 +7,6 @@ fn main()
io::stdin() io::stdin()
.read_line(&mut name) .read_line(&mut name)
.expect("Failded to read line"); .expect("Failded to read line");
name.pop();
println!("Hello, {}!", name); println!("Hello, {}!", name);
} }
fn main() fn
main()
{ {
let mut x : u32 = 3; let mut x : u32 = 3;
println!("{}", x); println!("{}", x);
x +=x; x +=x;
println!("{}", x); println!("{}", x);
} }
...@@ -4,7 +4,7 @@ fn main() ...@@ -4,7 +4,7 @@ fn main()
{ {
let car1 = Car{ let car1 = Car{
model: String::from("Model S"), model: String::from("Model S"),
brand: String::from("Tesla "), brand: String::from("Tesla"),
year: 2020 year: 2020
}; };
let car2 = Car{ let car2 = Car{
...@@ -20,8 +20,6 @@ fn main() ...@@ -20,8 +20,6 @@ fn main()
print_car_info(car1); print_car_info(car1);
print_car_info(car2); print_car_info(car2);
print_car_info(car3); print_car_info(car3);
} }
fn print_car_info(car:Car) fn print_car_info(car:Car)
......
use std::io;
fn main(){ fn main(){
println!("{}", fib(1, 0, 0, 5)); let mut Ns = String::new();
io::stdin()
.read_line(&mut Ns)
.expect("Failded to read line");
Ns.pop();
let N = Ns.parse::<u64>().unwrap();
println!("{}", fib(1, 0, 1, N));
} }
fn fib(curr_n:u64, prev_n:u64, recur:u64, end:u64) -> u64{ fn fib(curr_n:u64, prev_n:u64, recur:u64, end:u64) -> u64{
......
File added
...@@ -81,6 +81,4 @@ fn main() ...@@ -81,6 +81,4 @@ fn main()
for employee in developers{ for employee in developers{
println!("\t{} - {} - {}", employee.name, employee.position.position_to_string(), employee.salary); println!("\t{} - {} - {}", employee.name, employee.position.position_to_string(), employee.salary);
} }
} }
{"rustc_fingerprint":12329289877665479636,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.77.1 (7cf61ebde 2024-03-27)\nbinary: rustc\ncommit-hash: 7cf61ebde7b22796c69757901dd346d0fe70bd97\ncommit-date: 2024-03-27\nhost: x86_64-unknown-linux-gnu\nrelease: 1.77.1\nLLVM version: 17.0.6\n","stderr":""},"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/opt/rust-bin-1.77.1\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}} {"rustc_fingerprint":12329289877665479636,"outputs":{"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/opt/rust-bin-1.77.1\noff\npacked\nunpacked\n___\ndebug_assertions\noverflow_checks\npanic=\"unwind\"\nproc_macro\nrelocation_model=\"pic\"\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_equal_alignment=\"16\"\ntarget_has_atomic_equal_alignment=\"32\"\ntarget_has_atomic_equal_alignment=\"64\"\ntarget_has_atomic_equal_alignment=\"8\"\ntarget_has_atomic_equal_alignment=\"ptr\"\ntarget_has_atomic_load_store\ntarget_has_atomic_load_store=\"16\"\ntarget_has_atomic_load_store=\"32\"\ntarget_has_atomic_load_store=\"64\"\ntarget_has_atomic_load_store=\"8\"\ntarget_has_atomic_load_store=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_thread_local\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.77.1 (7cf61ebde 2024-03-27)\nbinary: rustc\ncommit-hash: 7cf61ebde7b22796c69757901dd346d0fe70bd97\ncommit-date: 2024-03-27\nhost: x86_64-unknown-linux-gnu\nrelease: 1.77.1\nLLVM version: 17.0.6\n","stderr":""},"14371922958718593042":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/opt/rust-bin-1.77.1\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment