string str(s)把char*s转化为string
find() 可以在指定字符串中查找完全匹配子串的位置
find_first_of() 在指定字符串中查找第一个任意匹配子串中字符的位置
find_first_not_of() 在指定字符串中查找第一个不任意匹配子串中字符的位置
class Solution {
public:
bool isNumber(const char *s) {
string str(s);
int index=str.find_first_not_of(' ');
if(str[index]=='+'||str[index]=='-')index++;
int points=0,numbers=0;
for(;str[index]>='0'&&str[index]<='9'||str[index]=='.';index++)
str[index]=='.'?points++:numbers++;
if(points>1||numbers<1)return false;
if(str[index]=='e'||str[index]=='E')
{
index++;
if(str[index]=='+'||str[index]=='-')
index++;
int afterE=0;
for(;str[index]>='0'&&str[index]<='9';index++)afterE++;
if(afterE<1)return false;
}
for(;str[index]==' ';index++){}
return str[index]=='\0';
}
};