fork download
  1. #include <iostream>
  2.  
  3. int StrToInt(std::string);
  4.  
  5. int main()
  6. {
  7. std::cout << StrToInt("9999XxX999") << std::endl;
  8.  
  9. return 0;
  10. }
  11.  
  12. int StrToInt(std::string str)
  13. {
  14. int convert_str = 0;
  15. std::string str_n = "0123456789";
  16.  
  17. for (int i = 0; i < str.size(); i++) {
  18. for (int cnt = 0; cnt < 10; cnt++)
  19. if (str[i] == str_n[cnt])
  20. convert_str = convert_str * 10 + cnt; continue;
  21. }
  22. if (str[0] == '-') return -convert_str;
  23. else return convert_str;
  24. }
  25.  
Success #stdin #stdout 0.01s 2856KB
stdin
Standard input is empty
stdout
9999999