mirror of
https://github.com/rust-lang/rustlings.git
synced 2026-01-03 17:29:18 +00:00
at exo 14
This commit is contained in:
parent
7c806e498a
commit
8594bab0d3
@ -13,8 +13,6 @@
|
||||
// Execute `rustlings hint intro1` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
fg
|
||||
|
||||
fn main() {
|
||||
println!("Hello and");
|
||||
println!(r#" welcome to... "#);
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
// Execute `rustlings hint intro2` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
fn main() {
|
||||
printline!("Hello there!")
|
||||
println!("Hello there!")
|
||||
}
|
||||
|
||||
@ -5,9 +5,9 @@
|
||||
// Execute `rustlings hint variables1` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
fn main() {
|
||||
x = 5;
|
||||
let x = 5;
|
||||
println!("x has the value {}", x);
|
||||
}
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
// Execute `rustlings hint variables2` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
fn main() {
|
||||
let x;
|
||||
let x = 10;
|
||||
if x == 10 {
|
||||
println!("x is ten!");
|
||||
} else {
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
// Execute `rustlings hint variables3` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
fn main() {
|
||||
let x: i32;
|
||||
let x: i32 = 7;
|
||||
println!("Number {}", x);
|
||||
}
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
// Execute `rustlings hint variables4` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
fn main() {
|
||||
let x = 3;
|
||||
let mut x = 3;
|
||||
println!("Number {}", x);
|
||||
x = 5; // don't change this line
|
||||
println!("Number {}", x);
|
||||
|
||||
@ -3,11 +3,11 @@
|
||||
// Execute `rustlings hint variables5` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
fn main() {
|
||||
let number = "T-H-R-E-E"; // don't change this line
|
||||
println!("Spell a Number : {}", number);
|
||||
number = 3; // don't rename this variable
|
||||
let number = 3; // don't rename this variable
|
||||
println!("Number plus two is : {}", number + 2);
|
||||
}
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
// Execute `rustlings hint variables6` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
const NUMBER = 3;
|
||||
|
||||
const NUMBER : i32 = 3;
|
||||
fn main() {
|
||||
println!("Number {}", NUMBER);
|
||||
}
|
||||
|
||||
@ -3,7 +3,11 @@
|
||||
// Execute `rustlings hint functions1` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
fn call_me() {
|
||||
|
||||
}
|
||||
|
||||
fn main() {
|
||||
call_me();
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
// Execute `rustlings hint functions2` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
fn main() {
|
||||
call_me(3);
|
||||
}
|
||||
|
||||
fn call_me(num:) {
|
||||
fn call_me(num: i32) {
|
||||
for i in 0..num {
|
||||
println!("Ring! Call number {}", i + 1);
|
||||
}
|
||||
|
||||
@ -3,10 +3,10 @@
|
||||
// Execute `rustlings hint functions3` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
fn main() {
|
||||
call_me();
|
||||
call_me(32);
|
||||
}
|
||||
|
||||
fn call_me(num: u32) {
|
||||
|
||||
@ -8,14 +8,14 @@
|
||||
// Execute `rustlings hint functions4` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
fn main() {
|
||||
let original_price = 51;
|
||||
println!("Your sale price is {}", sale_price(original_price));
|
||||
}
|
||||
|
||||
fn sale_price(price: i32) -> {
|
||||
fn sale_price(price: i32) -> i32{
|
||||
if is_even(price) {
|
||||
price - 10
|
||||
} else {
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
// Execute `rustlings hint functions5` or use the `hint` watch subcommand for a
|
||||
// hint.
|
||||
|
||||
// I AM NOT DONE
|
||||
|
||||
|
||||
fn main() {
|
||||
let answer = square(3);
|
||||
@ -11,5 +11,5 @@ fn main() {
|
||||
}
|
||||
|
||||
fn square(num: i32) -> i32 {
|
||||
num * num;
|
||||
num * num
|
||||
}
|
||||
|
||||
@ -2,9 +2,13 @@
|
||||
//
|
||||
// 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 {
|
||||
if a > b {
|
||||
return a;
|
||||
}
|
||||
b
|
||||
// Complete this function to return the bigger number!
|
||||
// Do not use:
|
||||
// - another function call
|
||||
|
||||
@ -9,10 +9,11 @@
|
||||
|
||||
pub fn foo_if_fizz(fizzish: &str) -> &str {
|
||||
if fizzish == "fizz" {
|
||||
"foo"
|
||||
} else {
|
||||
1
|
||||
return "foo";
|
||||
} else if fizzish == "fuzz" {
|
||||
return "bar";
|
||||
}
|
||||
"baz"
|
||||
}
|
||||
|
||||
// No test changes needed!
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user