class Solution {
public:
bool isNumber(string s) {
if(s == " ") return false;
int i = ;
int j = s.size()-;
while(s[i] == ' ') ++i;
while(s[j] == ' ') --j;
++j; if(s[i] == '+' || s[i] == '-') ++i; if(i == j) return false; bool numberic = true;
bool flag = false; int k = scanDigits(s,i,j);
if (k != i)
{
flag = true;
} i = k; if(i < j){
if(s[i] == '.'){
++i;
if(i == j && !flag) return false;
else
{
k = scanDigits(s,i,j);
if (k != i)
{
flag = true;
}
i = k;
if(i < j && (s[i] == 'E'||s[i] == 'e'))
numberic = flag && isExponential(s, (++i),j);
} }
else if(i < j && (s[i] == 'E'||s[i] == 'e'))
numberic = flag && isExponential(s, ++i,j);
else numberic = false;
} return numberic && i == j; } int scanDigits(string str, int i,int j){
while(i < j && str[i] >= ''&& str[i] <= '') ++i;
return i;
} bool isExponential(string str, int& i, int j){
if(i == j) return false;
if(str[i] == '+' || str[i] == '-') ++i; if(i == j) return false;
i = scanDigits(str,i,j);
return i==j?true:false;
}
};

测试了好多次才过了 太不容易 所以贴个上来做下纪念

".9e1","+.1"  "1."都正确

Valid Number--LeetCode的更多相关文章

  1. Valid Number leetcode java

    题目: Validate if a given string is numeric. Some examples: "0" => true " 0.1 " ...

  2. 【LeetCode】65. Valid Number

    Difficulty: Hard  More:[目录]LeetCode Java实现 Description Validate if a given string can be interpreted ...

  3. 【leetcode】Valid Number

    Valid Number Validate if a given string is numeric. Some examples:"0" => true" 0.1 ...

  4. [leetcode]65. Valid Number 有效数值

    Validate if a given string can be interpreted as a decimal number. Some examples:"0" => ...

  5. LeetCode: Valid Number 解题报告

    Valid NumberValidate if a given string is numeric. Some examples:"0" => true" 0.1 ...

  6. leetCode 65.Valid Number (有效数字)

    Valid Number  Validate if a given string is numeric. Some examples: "0" => true " ...

  7. [LintCode] Valid Number 验证数字

    Validate if a given string is numeric. Have you met this question in a real interview? Yes Example & ...

  8. [Swift]LeetCode65. 有效数字 | Valid Number

    Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => ...

  9. Valid Number @python

    Valid Number Validate if a given string is numeric. Some examples:"0" => true" 0.1 ...

  10. 配置域名服务器报错named[822]: dns_rdata_fromtext /etc/bind/db.asertest.com mail not a valid number

    问题描述: 为了配置邮件服务器,更改了相关域名,改完后,重启bind9报错 Mar 17 14:39:39 DnsServer2 named[822]: dns_rdata_fromtext: /et ...

随机推荐

  1. C#的FTP上传下载的实验

    前段时间做了一个FTP操作服务器文件的实验,现在把一些经验写下来,免得忘记. 1.上传的处理:目标文件夹A上传到服务器指定目录.先检索服务器目录中有无同名文件夹,若有,则先改名,上传成功后再删除,上传 ...

  2. bootstrp-select插件使用

    需要导入 <link rel="stylesheet" href="js/plugins/silviomoreto-bootstrap-select20151109 ...

  3. Flood it 游戏

    致敬HDU4127做的一个小游戏(数据结构大作业没东西写就搞这个了QAQ). 游戏截图(当然上交版本就没这么暴力拉): GUI界面选用的是Qt,由于之前没有接触过相关的东西,入门Qt花了不少时间. 大 ...

  4. smbaclient

    在linux中通过smbaclient获取windows的共享文件 列出windows的共享目录 $ smbclient -L .xxx -U administrator%password 进入指定共 ...

  5. tuple 可更改的列表和不可更改的元组

    tuple([iterable]) Return a tuple whose items are the same and in the same order as iterable's items. ...

  6. 关于react-native遇到Can't find variable: TouchableHighlight

    当你遇到这样的问题时,是由于你没有import中添加TouchableHighlight import { AppRegistry, StyleSheet, Text, View, PixelRati ...

  7. netty(5)高级篇-私有协议栈

    来源:<Netty权威指南>  作者:李林峰 一.私有协议介绍 由于现代软件的复杂性,一个大型软件系统往往会被人为地拆分称为多个模块,另外随着移动互联网的兴起,网站的规模越来越大,业务功能 ...

  8. 提示找不到xml配置文件

    ClassPathXmlApplicationContext("applicationContext.xml")默认文件夹是resouerces,所以要把xml文件放在这个下面.

  9. Atom编辑器之加快React开发的插件汇总

    汇总下比较实用的atom插件[偏react开发的]-- 博主发现这个还是比较全面的! atom-react-autocomplete–项目内,组件名及状态的自动补全  autocomplete-js- ...

  10. jQuery中操作Ajax方法小结

    有时候,越深入去了解一个点,越发觉得自己无知,而之前当自己晓得一两个片面的点还洋洋自得,殊不知,这是多么讽刺 jQery对Ajax操作进行了封装,常见的 ajax()属于最底层的方法,使用频率很高的 ...