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
Hello World
List add
scuba
Quiz 12/13
Problema1
Tubee c++
Common elements in 3 sorted vectors with extra space
point to a rvalue
logcOperator
Microsoft - MaxEmployeeAttendence (R repititions - DP solution bitmask)