Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ZADANIE 5
- public static Boolean anagramy(String napis1, String napis2)
- {
- string trim1 = Regex.Replace(napis1, @"s", "");
- string trim2 = Regex.Replace(napis2, @"s", "");
- trim1 = trim1.ToLower();
- trim2 = trim2.ToLower();
- if (trim1.Length != trim2.Length)
- return false;
- else
- {
- for (int i = 0; i < trim1.Length; i++)
- {
- int liczbaLiter1 = 0;
- int liczbaLiter2 = 0;
- for (int j = 0; j < trim1.Length; j++)
- {
- if (trim1[i] == trim1[j])
- liczbaLiter1++;
- if (trim1[i] == trim2[j])
- liczbaLiter2++;
- }
- if (liczbaLiter1 != liczbaLiter2)
- return false;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement