LeetCode--Valid Number

这道题真心是难度比较大,不是算法难度,是实现难度,

各种case都得考虑到。

我没有A过,一开始就把.1这种case当做是错误的。导致程序逻辑乱套了。

下面是别人的代码:

 1 class Solution {
 2 public:
 3     bool isNumber(const char *s) {
 4         // Start typing your C/C++ solution below
 5         // DO NOT write int main() function
 6         if (s == NULL)
 7             return false;
 8             
 9         while(isspace(*s))
10             s++;
11             
12         if (*s == '+' || *s == '-')
13             s++;
14             
15         bool eAppear = false;
16         bool dotAppear = false;
17         bool firstPart = false;
18         bool secondPart = false;
19         bool spaceAppear = false;
20         while(*s != '