0
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?

[paiza]レベルアップ問題集解答案(C#)【配列の検索】何個ある? Boss

Last updated at Posted at 2024-09-26

問題

C#解答案

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        // 1行目: 整数N, Mを取得
        int[] num = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

        // 2行目: M個の整数を取得し、配列に格納
        int[] list = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

        // リストからNの数を数える
        IEnumerable<int> li = list.Where(o => o == num[0]);
        //var li = list.Where(o => o == num[0]);

        // Nがいくつあったかを出力
        Console.WriteLine(li.Count());
    }
}
0
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
0
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?