Aliendreamer

how many times element shows up in array

Jun 19th, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _11ExtendedHowManytimesElementIsinArray
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] num =Console.ReadLine().Split().Select(int.Parse).ToArray();
  14.             int match = int.Parse(Console.ReadLine());
  15.             int count = 0;
  16.            
  17.  
  18.             foreach (int a in num)
  19.             {
  20.                 if (a == match)
  21.                 {
  22.                     count++;
  23.                 }
  24.                 else
  25.                 {
  26.                     continue;
  27.                 }
  28.  
  29.             }
  30.             Console.WriteLine(count);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment