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 ConsoleApplication7
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string pattern = Console.ReadLine();
- Console.WriteLine(Occurrences(input, pattern));
- }
- static int Occurrences(string longWord, string shortWord)
- {
- int counter = 0;
- int lengthPattern = shortWord.Length;
- for (int i = 0; i <= longWord.Length - lengthPattern; i++)
- {
- if (longWord.ToLower().IndexOf(shortWord.ToLower(), i, lengthPattern) != -1)
- {
- counter++;
- }
- }
- return counter;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment