pszot

Untitled

Nov 4th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3.  
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             ArrayList lista = new ArrayList();
  9.  
  10.             int wynik = 0;
  11.  
  12.             string tekst = Console.ReadLine();
  13.             string[] split = tekst.Split(' ');
  14.  
  15.             int poszukiwana = int.Parse(split[0]);
  16.             int ileLiczb = int.Parse(split[1]);
  17.  
  18.             for (int j = 0; j < ileLiczb; j++)
  19.             {
  20.                 int liczba = int.Parse(split[j + 2]);
  21.                 lista.Add(liczba);
  22.             }
  23.  
  24.             foreach (int liczba in lista)
  25.             {
  26.                 if (liczba == poszukiwana)
  27.                 {
  28.                     wynik++;
  29.                 }
  30.             }
  31.             Console.WriteLine(wynik);
  32.             Console.ReadKey();
  33.         }
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment