Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string a = "abd";
- int count=0;
- char[] b = new char[] { 'a', 'f', 'g','a', 'b', 'd', 'o', 'c', 'a', 'v', 'g', 'h', 's' };
- for (int i = 0; i < b.Length - 1 - a.Length; i++)
- {
- if(a.Length==1 && a[i]==a[0] )
- {
- count++;
- }
- if (a.Length == 2 && b[i] == a[0]&& b[i+1]==a[1])
- {
- count++;
- }
- if (a.Length == 3 && b[i] == a[0] && b[i + 1] == a[1] && b[i + 2] == a[2])
- {
- count++;
- }
- }
- Console.WriteLine(count);
Add Comment
Please, Sign In to add comment