Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool balanced(string text, char a, char b)
- {
- char[] temp = text.ToCharArray();
- int[] counter = { 0, 0 };
- for (int i = 0; i < text.Length; i++)
- {
- if (temp[i] == a)
- counter[0] += 1;
- if (temp[i] == b)
- counter[1] += 1;
- }
- if (counter[0] == counter[1])
- return true;
- else
- return false;
- }
Add Comment
Please, Sign In to add comment