-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzad1.2.cs
47 lines (41 loc) · 1.33 KB
/
zad1.2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void ZnakiLicz(ref string[] tab, ref int wynik, string znak)
{
for (int i = 0; i < tab.Length; i++)
{
if (tab[i] == znak)
{
wynik++;
}
}
}
static void Main(string[] args)
{
string[] tablica = { "a", "b", "c", "d", "a", "a", "c", "a"};
string znak;
int wynik = 0;
Console.WriteLine("Projekt 2 - tablica i znaki");
foreach (string ele in tablica) //Wypisanie całej tabeli w konsoli.
Console.Write(ele + " ");
Console.ReadLine();
Console.WriteLine("\n" + "Co szukać w tabeli: ");
znak = Convert.ToString(Console.ReadLine());
ZnakiLicz(ref tablica, ref wynik, znak);
Console.WriteLine("\n" + "Ilość szukanego elementu: " + wynik); /*
if (tablica.Contains("c")) // Wyszukanie elementu w tablicy
{
Console.WriteLine("\n" + "Element znajduje się w tablicy.");
}
*/
Console.ReadLine();
}
}
}