class Solution {public: const int _MAX=0x7fffffff,_MIN=0x80000000; int myAtoi(string str) { long long int val=0; int i=0,flag=1; while(str[i]==' ') ++i; if(str[i]=='-') flag=-1,++i; else if(str[i]=='+') ++i; while(i='0' && str[i]<='9'){ val=val*10+str[i]-'0'; if(flag*val>=_MAX) return _MAX; if(flag*val<=_MIN) return _MIN; ++i; } return flag*val; }};