Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Nth/Rust/nth.rust
Normal file
20
Task/Nth/Rust/nth.rust
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
fn nth(num: isize) -> String {
|
||||
format!("{}{}", num, match (num % 10, num % 100) {
|
||||
(1, 11) | (2, 12) | (3, 13) => "th",
|
||||
(1, _) => "st",
|
||||
(2, _) => "nd",
|
||||
(3, _) => "rd",
|
||||
_ => "th",
|
||||
})
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let ranges = [(0, 26), (250, 266), (1000, 1026)];
|
||||
for &(s, e) in &ranges {
|
||||
println!("[{}, {}) :", s, e);
|
||||
for i in s..e {
|
||||
print!("{}, ", nth(i));
|
||||
}
|
||||
println!();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue