Guest User

Untitled

a guest
Feb 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1.         public bool balanced(string text, char a, char b)
  2.         {
  3.             char[] temp = text.ToCharArray();
  4.             int[] counter = { 0, 0 };
  5.             for (int i = 0; i < text.Length; i++)
  6.             {
  7.                 if (temp[i] == a)
  8.                     counter[0] += 1;
  9.                 if (temp[i] == b)
  10.                     counter[1] += 1;
  11.             }
  12.             if (counter[0] == counter[1])
  13.                 return true;
  14.             else
  15.                 return false;
  16.         }
Add Comment
Please, Sign In to add comment