mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-09 20:29:18 +00:00
fix: worked till if and quiz 1
This commit is contained in:
parent
59e0adb455
commit
e47d4c4c06
@ -1,13 +1,12 @@
|
|||||||
// if1.rs
|
// if1.rs
|
||||||
// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint.
|
// Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
pub fn bigger(a: i32, b: i32) -> i32 {
|
pub fn bigger(a: i32, b: i32) -> i32 {
|
||||||
// Complete this function to return the bigger number!
|
if(a>b){
|
||||||
// Do not use:
|
return a;
|
||||||
// - another function call
|
}else{
|
||||||
// - additional variables
|
return b;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't mind this for now :)
|
// Don't mind this for now :)
|
||||||
|
|||||||
@ -4,14 +4,17 @@
|
|||||||
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
|
// Step 2: Get the bar_for_fuzz and default_to_baz tests passing!
|
||||||
// Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint.
|
// Execute `rustlings hint if2` or use the `hint` watch subcommand for a hint.
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
pub fn foo_if_fizz(fizzish: &str) -> &str {
|
pub fn foo_if_fizz(fizzish: &str) -> &str {
|
||||||
if fizzish == "fizz" {
|
if fizzish == "fizz" {
|
||||||
"foo"
|
"foo"
|
||||||
} else {
|
} else {
|
||||||
1
|
if fizzish =="fuzz"{
|
||||||
|
"bar"
|
||||||
|
}else{
|
||||||
|
"baz"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No test changes needed!
|
// No test changes needed!
|
||||||
|
|||||||
@ -10,10 +10,18 @@
|
|||||||
// Write a function that calculates the price of an order of apples given
|
// Write a function that calculates the price of an order of apples given
|
||||||
// the quantity bought. No hints this time!
|
// the quantity bought. No hints this time!
|
||||||
|
|
||||||
// I AM NOT DONE
|
|
||||||
|
|
||||||
// Put your function here!
|
// Put your function here!
|
||||||
// fn calculate_price_of_apples {
|
fn calculate_price_of_apples(no_of_apples:i32)->i32{
|
||||||
|
let mut price_of_apples :i32;
|
||||||
|
if no_of_apples >40{
|
||||||
|
price_of_apples = no_of_apples;
|
||||||
|
}else{
|
||||||
|
price_of_apples = 2*no_of_apples;
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Price of {} is {}",no_of_apples, price_of_apples);
|
||||||
|
return price_of_apples;
|
||||||
|
}
|
||||||
|
|
||||||
// Don't modify this function!
|
// Don't modify this function!
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user