Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool swap(wchar_t* string1, wchar_t* string2)
- {
- size_t s1 = wcslen(string1);
- size_t s2 = wcslen(string2);
- if (s1 == 0 && s2 == 0) //dva kratke neni nutne prehazovat
- return false;
- if (s2 == 0)
- return true;
- else if (s1 == 0)
- return false;
- size_t i1 = 0, i2 = 0;
- wchar_t l1 = string1[0];
- wchar_t l2 = string2[0];
- wchar_t c1, c2;
- while(i1 < s1 && i2 < s2)
- {
- c1 = i1 < s1 ? string1[i1] : ' ';
- c2 = i2 < s2 ? string2[i2] : ' ';
- if (i1 < s1 && iswspace(l1) && iswspace(c1))
- {
- i1++;
- continue;
- }
- if (i2 < s2 && iswspace(l2) && iswspace(c2))
- {
- i2++;
- continue;
- }
- if (table[c1] > table[c2])
- return true;
- i1++;
- i2++;
- l1 = c1;
- l2 = c2;
- }
- l1 = string1[0];
- l2 = string2[0];
- while(i1 < s1 && i2 < s2)
- {
- c1 = i1 < s1 ? string1[i1] : ' ';
- c2 = i2 < s2 ? string2[i2] : ' ';
- if (i1 < s1 && iswspace(l1) && iswspace(c1))
- {
- i1++;
- continue;
- }
- if (i2 < s2 && iswspace(l2) && iswspace(c2))
- {
- i2++;
- continue;
- }
- if (table2[c1] > table2[c2])
- return true;
- i1++;
- i2++;
- l1 = c1;
- l2 = c2;
- }
- return false;
- }
Add Comment
Please, Sign In to add comment