Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _16.Counting_a_Word_in_a_Text
- {
- class CountingWordText
- {
- static void Main(string[] args)
- {
- Console.Write("Enter your word: ");
- string word = Console.ReadLine().ToLower();
- Console.WriteLine("Enter your text.");
- string rowText = Console.ReadLine().ToLower();
- int counter = 0;
- string[] text = rowText.Split(' ', '(', ')', '.', '+', ',', '"', '/', '@', '!');
- if (text.Contains(word))
- {
- foreach (var item in text)
- {
- if (item == word)
- {
- counter++;
- }
- }
- Console.WriteLine("Times used --> {0}", counter);
- }
- else
- {
- Console.WriteLine("Times used --> {0}", counter);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement