Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
str_to_int
//Title of this code #include <iostream> #include <string> using namespace std; long long str_to_int(const string& s) { long long num = 0; int j = 1; for (int i = s.length() - 1; i >= 0; --i){ if (s[i] >= '0' && s[i] <= '9') num += static_cast<int>(s[i] - '0') * j; else return -1; j *= 10; } return num; } int main() { cout << str_to_int("0100") << endl; std::cout << "Hello, world!\n"; }
run
|
edit
|
history
|
help
0
134
DP Optimization another kind
C++
read_write_lock_acc
Assigment operator (easy)
test yield
multimap
Destroy It!
Constructor.cpp
Roger Cheng