Guest User

Untitled

a guest
May 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1.  string a = "abd";
  2.             int count=0;
  3.             char[] b = new char[] { 'a', 'f', 'g','a', 'b', 'd', 'o', 'c', 'a', 'v', 'g', 'h', 's' };
  4.             for (int i = 0; i < b.Length - 1 - a.Length; i++)
  5.             {
  6.                 if(a.Length==1 && a[i]==a[0] )
  7.                 {
  8.                 count++;
  9.                 }
  10.                 if (a.Length == 2 && b[i] == a[0]&& b[i+1]==a[1])
  11.                 {
  12.                     count++;
  13.                 }
  14.                 if (a.Length == 3 && b[i] == a[0] && b[i + 1] == a[1] && b[i + 2] == a[2])
  15.                 {
  16.                     count++;
  17.                 }
  18.             }
  19.             Console.WriteLine(count);
Add Comment
Please, Sign In to add comment