烂做🥴😖
int myAtoi(char * s){
long long int res=0;
int len=strlen(s),i=0;
while(s[i]==' '){
i+=1;
}
bool a=0;
if(s[i]=='-'){
a=1;
i+=1;
if(s[i]>'9'||s[i]<'0')
return 0;
}
if(s[i]=='+')
i+=1;
if(s[i]>'9'||s[i]<'0')
return 0;
while(i<len){
if(s[i]>'9'||s[i]<'0')
break;
if(res>2147483648)
return a?-2147483648:2147483647;
res=res*10+s[i]-'0';
i+=1;
}
res=a?-res:res;
if(res<-2147483648)
return -2147483648;
if(res>2147483647)
return 2147483647;
return res;
}