问题描述:
Validate if a given string is numeric.
Some examples:
“0” => true
” 0.1 ” => true
“abc” => false
“1 a” => false
“2e10” => true
Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one.
代码分析:这道题巨**恶心,关键是有些规则并不清楚,需要一次一次的得到测试用例之后才知道规则。另外,这道题建议分开写,而不是混杂在一起,实在是太乱了。总的来说,如果存在e,那么e之前一定为一个float,后面为一个整数。如果不存在e,就检查整体是否为float。
代码如下:8ms
bool checkFloat(char *s,int start,int end){
if(start>end)
return false;