1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

初心者プログラマーAtCoderに挑んだ軌跡-ABC421-A-

Posted at

ABC421-A

問題の内容

配列検索
N部屋のX番目の住人がYであるかどうかの検索

言語

Rust

解法

input後、配列S[x]==yならYes他は全部No

課題

  • s[x]としたが、s[x-1]が正しい
  • 文字配列のinput
  • if文の書き方

学んだこと

  • Rustは「配列は0から」系言語
  • 配列のinputは
input! {
    s: [();(個数)]
}
  • if文は
if 条件 {  //()はいらない
    処理を書く
}

提出内容

use proconio::input;

fn main() {
    input! {
        n: usize,
        s: [String; n],  //配列のinput
        x: usize,
        y: String,
    }

    if s[x - 1] == y { //0から配列なので-1
        println!("Yes");
    } else {
        println!("No");
    }
}

成績

  • 241Byte
  • AC
  • 0ms
  • 1968KiB
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?