fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <memory.h>
  5. using namespace std;
  6.  
  7. bool relative(const string& s1, const string& s2)
  8. {
  9. bool v1[256] = {false}, v2[256] = {false};
  10. for(auto c: s1) v1[c] = true;
  11. for(auto c: s2) v2[c] = true;
  12. return memcmp(v1,v2,sizeof(v1)) == 0;
  13. // Или можно так:
  14. // for(int i = 0; i < 256; ++i) if (v1[i] != v2[i]) return false;
  15. // return true;
  16. }
  17.  
  18. int main() {
  19. cout << relative("baran","baraban") << endl;
  20. cout << relative("baran","baranka") << endl;
  21. return 0;
  22. }
Success #stdin #stdout 0s 16056KB
stdin
Standard input is empty
stdout
1
0