GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Embed Notice

HTML Code

Corresponding Notice

  1. Embed this notice
    夜化 (yoruka@eientei.org)'s status on Tuesday, 06-May-2025 18:08:00 JST夜化夜化
    in reply to
    • Zergling_man
    • Protoss
    • waff
    @Cyrillic @waff @Zergling_man In case anyone doesn't know, its really bad
    use rand::Rng;
    use std::io;
    use std::cmp::Ordering;

    fn main() {
    let generated_number = rand::thread_rng().gen_range(1..101);
    let mut tries: u32 = 0;

    println!("{}", generated_number);

    println!("I generated a number, now guess what it is.\n");

    loop {
    tries += 1;

    println!("Input a number:");

    let mut guessed_number = String::new();
    io::stdin()
    .read_line(&mut guessed_number)
    .expect("failed to read line.");

    let guessed_number: u32 = match guessed_number.trim().parse() {
    Ok(num) => num,
    Err(_) => continue,
    };

    match guessed_number.cmp(&generated_number) {
    Ordering::Less => println!("too small"),
    Ordering::Greater => println!("too big"),
    Ordering::Equal => {
    println!("you win!");
    println!("You made {} attempts.", tries);
    break;
    }
    }
    }
    }
    In conversationabout 14 days ago from eientei.orgpermalink
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.