fork(2) download
  1. #include <iostream>
  2.  
  3. constexpr unsigned int s2i(const char*, int = 0);
  4.  
  5. constexpr unsigned int Str2Int(const char *Line, int CurrentPos = 0)
  6. {
  7. return !Line[CurrentPos] ? 5381 : (Str2Int(Line, CurrentPos + 1) * 33) ^ Line[CurrentPos];
  8. }
  9.  
  10. int main()
  11. {
  12. std::cout << Str2Int("3") << '\n';
  13. std::cout << s2i("3") << '\n' ;
  14. }
  15.  
  16. constexpr unsigned int s2i(const char* Line, int CurrentPos)
  17. {
  18. return !Line[CurrentPos] ? 5381 : (Str2Int(Line, CurrentPos + 1) * 33) ^ Line[CurrentPos];
  19.  
  20. }
  21.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
177558
177558