思路:模拟正则表达式
    状态机如下:
    TIM图片20200326123834.jpg

    1. bool isNumeric(char* string)
    2. {
    3. int i = 0;
    4. if(string[i]=='+' || string[i]=='-' || IsNum(string[i])){
    5. while(string[++i]!='\0' && IsNum(string[i]));
    6. if(string[i]=='.'){
    7. if(IsNum(string[++i])){
    8. while(string[++i]!='\0' && IsNum(string[i]));
    9. if(string[i]=='e'||string[i]=='E'){
    10. i++;
    11. if(string[i]=='+' || string[i]=='-' || IsNum(string[i])){
    12. while(string[++i]!='\0' && IsNum(string[i]));
    13. if(string[i]=='\0') return true;
    14. else return false;
    15. }else return false;
    16. }else if(string[i]=='\0') return true;
    17. else return false;
    18. }else if(string[++i]=='\0') return true;
    19. else return false;
    20. }else if(string[i]=='e'||string[i]=='E'){
    21. i++;
    22. if(string[i]=='+' || string[i]=='-' || IsNum(string[i])){
    23. while(string[++i]!='\0' && IsNum(string[i]));
    24. if(string[i]=='\0') return true;
    25. else return false;
    26. }else return false;
    27. }else if(string[i]=='\0') return true;
    28. else return false;
    29. }else return false;
    30. }
    31. bool IsNum(char ch)
    32. {
    33. if(ch<'0'||ch>'9') return false;
    34. else return true;
    35. }