1、声明tmp1和tmp2去记录前后两个数。
然后去遍历数组读取其中的数字即可。
class Solution {
public:
bool areNumbersAscending(string s) {
int i=0,tmp1=0,tmp2=0,thesize=s.size();
while(i<thesize)
{
if(s[i]<='9'&&s[i]>='0')
{
while(s[i]!=' '&&i<thesize)
{
tmp1=tmp1*10+s[i]-'0';
++i;
}
if(tmp2!=0 && tmp1<=tmp2) return false;
else
{
tmp2=tmp1;
tmp1=0;
}
}
++i;
}
return true;
}
};