# 有效数字（LeetCode）

#include<bits/stdc++.h>
using namespace std;
bool isNumber(string s)
{
s.erase(0,s.find_first_not_of(" "));
s.erase(s.find_last_not_of(" ")+1);
if(s[0]!='-'&&!(s[0]>='0'&&s[0]<='9')&&s[0]!='.'&&s[0]!='+')
return false;
else
{
int type = 0;
int count = 0;
if(s[0]=='.'&&s.length()==1)
return false;
if(s[0] == '.')
count++;
for(int i=1; i<s.length(); i++)
{
if(s[i]!='e'&&s[i]!='.'&&s[i]!='-'&&!(s[i]>='0'&&s[i]<='9'))
return false;
if(s[i]=='e')
{
if(type==1)
return false;
type = 1;
if(i==s.length()-1)
return false;
if(s[i-1]=='0'&&i==s.length()-1)
return false;
if(((s[i-1]>='0'&&s[i-1]<='9')||(s[i-1]=='.'&&i-1!=0))&&(s[i+1]>='0'&&s[i+1]<='9'))
i++;
else if(((s[i-1]>='0'&&s[i-1]<='9')||s[i-1]=='.'&&i-1!=0)&&s[i+1]=='-')
i++;
else if((s[i-1]>='0'&&s[i-1]<='9')&&s[i+1]=='+'&&i+1!=s.length()-1)
i++;
else
return false;
}
if(s[i]=='-')
{
if(s[i-1]!='e'||i==s.length()-1||!(s[i+1]>='0'&&s[i+1]<='9'))
return false;
}
if(s[i]=='.')
{
count++;
if(count!=1||type == 1)
return false;
if((s[i-1]>='0'&&s[i-1]<='9'))
{
if(s[0]=='.')
return false;
else
continue;
}else if(s[i-1]=='+'&&i-1==0&&i!=s.length()-1)
continue;
else if(s[i-1]=='-'&&i-1==0&&i!=s.length()-1)
continue;
else
return false;
}
}
return true;
}
}
int main()
{
string s;
cin>>s;
cout<<isNumber(s)<<endl;
}


03-25 202
02-14 140

12-26 420
03-03 86
03-21 212
10-18 249