結果

問題 No.264 じゃんけん
ユーザー triggerwaffletriggerwaffle
提出日時 2020-09-02 02:26:01
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 706 bytes
コンパイル時間 14,561 ms
コンパイル使用メモリ 387,304 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 05:03:13
合計ジャッジ時間 12,816 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
6,812 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 0 ms
6,944 KB
testcase_07 WA -
testcase_08 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: value assigned to `ans` is never read
  --> src/main.rs:19:13
   |
19 |     let mut ans = String::new();
   |             ^^^
   |
   = help: maybe it is overwritten before being read?
   = note: `#[warn(unused_assignments)]` on by default

warning: value assigned to `ans` is never read
  --> src/main.rs:20:19
   |
20 |     if a-b == 0 { ans = String::from("Drew"); }
   |                   ^^^
   |
   = help: maybe it is overwritten before being read?

warning: value assigned to `ans` is never read
  --> src/main.rs:21:20
   |
21 |     if a-b == -2 { ans = String::from("Lose"); }
   |                    ^^^
   |
   = help: maybe it is overwritten before being read?

ソースコード

diff #

use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i64 = read(); // (*)
    let b: i64 = read();
    let mut ans = String::new();
    if a-b == 0 { ans = String::from("Drew"); }
    if a-b == -2 { ans = String::from("Lose"); }
    if a-b == 1 { ans = String::from("Lose"); }
    else {ans = String::from("Won");}
    println!("{}", ans);
}
0