Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- _Bool areAnagrams(const char* strA, const char* strB)
- {
- char *pomA = strA;
- char *pomB = strB;
- int pole1[128] = { 0 }, pole2[128] = { 0 }; // cca 128 zakladnych znakov v ASCII tabulke
- char aktualnyChar;
- while(*pomA != '\0')
- {
- aktualnyChar = *pomA;
- pole1[aktualnyChar]++;
- pomA++;
- }
- while(*pomB != '\0')
- {
- aktualnyChar = *pomB;
- pole2[aktualnyChar]++;
- pomB++;
- }
- for (int i = 0; i < 128; i++)
- {
- if (pole1[i] != pole2[i])
- return false;
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement