Advertisement
skipter

C# Count The Equal Elements in Array

Jun 23rd, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 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 _11.CountOfElemnts
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] arrayTokens = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14.             int currentToken = int.Parse(Console.ReadLine());
  15.             int counter = 0;
  16.             for (int cnt = 0; cnt < arrayTokens.Length; cnt++)
  17.             {
  18.                 if (arrayTokens[cnt] == currentToken)
  19.                 {
  20.                     counter++;
  21.                 }
  22.             }
  23.             Console.WriteLine(counter);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement