标签:
bool isNum(const string& str) { bool bRet = false; bool point = false; if(str.length() == 0) { return bRet; } if (!isdigit(str[0]) && str[0] != ‘+‘ && str[0] != ‘-‘ ) { return bRet; } if (str[1] == ‘.‘ && (str[0] == ‘+‘ || str[0] == ‘-‘)) { return bRet; } for ( int i = 1; i < str.length(); i++ ) { if (!isdigit(str[i])) { if (str[i] == ‘.‘ && !point) { point = true; } else { return bRet; } } } return true; }
标签:
原文地址:http://www.cnblogs.com/kaishan1990/p/5339488.html