fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. class StrCmp
  5. {
  6. public:
  7. template <typename T> bool operator()
  8. (const T* p1, const T* p2) const
  9. {
  10. while (*p1 && *p2 && *p1 == *p2)
  11. ++p1, ++p2;
  12.  
  13. return *p2 - *p1 > 0;
  14. }
  15. };
  16.  
  17. int main(int argc, char* argv[] )
  18. {
  19. const unsigned int* a[]
  20. {
  21. (const unsigned int*)"Сидоров",
  22. (const unsigned int*)"Петров",
  23. (const unsigned int*)"Иванов",
  24. (const unsigned int*)"Аров",
  25. (const unsigned int*)"Аро",
  26. (const unsigned int*)"",
  27. };
  28.  
  29. std::cout << StrCmp()(a[2],a[5]) << std::endl;
  30. std::cout << StrCmp()(a[5],a[2]) << std::endl;
  31.  
  32. return 0;
  33. }
  34.  
  35.  
Success #stdin #stdout 0s 4532KB
stdin
Standard input is empty
stdout
1
1