Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
PayTax
Wipro Problem 1: generate roll number
abhilash
MinCostKStops_BFS
Weighted Index
variadic pointer to function template
RecursiveFact
Bin Tree playground
Kth smallest element
thermal_containers
Please log in to post a comment.