第八题
class Solution {
public:
int myAtoi(string str) {
int i = ;
long sum = ;
int sign = ;
while(str[i] == ' ')i++;
if (str[i] == '-'|| str[i] == '+')
{
if(str[i] == '-') sign = -;
i++;
}
while(str[i]<='' && str[i]>='')
{
if(sum>=INT_MAX) break;
sum = sum * + str[i++] - '';
}
sum*=sign;
if(sum>=INT_MAX)return INT_MAX;
if(sum<=INT_MIN)return INT_MIN;
return sum;
}
};