complete: variables

This commit is contained in:
YeSifan 2021-06-19 20:29:30 +08:00
parent 59d87b88f0
commit a982cd5e7f
6 changed files with 5 additions and 18 deletions

View file

@ -6,8 +6,6 @@
// even after you already figured it out. If you got everything working and // even after you already figured it out. If you got everything working and
// feel ready for the next exercise, remove the `I AM NOT DONE` comment below. // feel ready for the next exercise, remove the `I AM NOT DONE` comment below.
// I AM NOT DONE
fn main() { fn main() {
const X: u8 = 5; const X: u8 = 5;
println!("x has the value {}", X); println!("x has the value {}", X);

View file

@ -1,10 +1,8 @@
// variables2.rs // variables2.rs
// Make me compile! Execute the command `rustlings hint variables2` if you want a hint :) // Make me compile! Execute the command `rustlings hint variables2` if you want a hint :)
// I AM NOT DONE
fn main() { fn main() {
let x; let x:u8 = 1;
if x == 10 { if x == 10 {
println!("Ten!"); println!("Ten!");
} else { } else {

View file

@ -1,10 +1,8 @@
// variables3.rs // variables3.rs
// Make me compile! Execute the command `rustlings hint variables3` if you want a hint :) // Make me compile! Execute the command `rustlings hint variables3` if you want a hint :)
// I AM NOT DONE
fn main() { fn main() {
let x = 3; let mut x = 3;
println!("Number {}", x); println!("Number {}", x);
x = 5; // don't change this line x = 5; // don't change this line
println!("Number {}", x); println!("Number {}", x);

View file

@ -1,9 +1,7 @@
// variables4.rs // variables4.rs
// Make me compile! Execute the command `rustlings hint variables4` if you want a hint :) // Make me compile! Execute the command `rustlings hint variables4` if you want a hint :)
// I AM NOT DONE
fn main() { fn main() {
let x: i32; let x: i32 = -1;
println!("Number {}", x); println!("Number {}", x);
} }

View file

@ -1,11 +1,8 @@
// variables5.rs // variables5.rs
// Make me compile! Execute the command `rustlings hint variables5` if you want a hint :) // Make me compile! Execute the command `rustlings hint variables5` if you want a hint :)
// I AM NOT DONE
fn main() { fn main() {
let number = "T-H-R-E-E"; let number = 3;
println!("Spell a Number : {}", number); println!("Spell a Number : {}", number);
number = 3;
println!("Number plus two is : {}", number + 2); println!("Number plus two is : {}", number + 2);
} }

View file

@ -1,9 +1,7 @@
// variables6.rs // variables6.rs
// Make me compile! Execute the command `rustlings hint variables6` if you want a hint :) // Make me compile! Execute the command `rustlings hint variables6` if you want a hint :)
// I AM NOT DONE const NUMBER:u8 = 3;
const NUMBER = 3;
fn main() { fn main() {
println!("Number {}", NUMBER); println!("Number {}", NUMBER);
} }