@[丸子粥](/space/show?uid=199043) 第一次循环
`(sentence.substr(i-k-1,k)`->`(sentence.substr(0-0-1,k)`->`(sentence.substr(-1,k)`
哦豁,完蛋
by 木木! @ 2019-08-01 19:20:41
1. a有可能炸掉
2. getline不好
by AlgoEmperor @ 2019-08-01 19:20:47
@[Ofnoname](/space/show?uid=73489) cin不能输入空格啊 我太难了
by 丸子粥 @ 2019-08-01 19:23:27
@[木木!](/space/show?uid=49458) 欧欧 我改改
by 丸子粥 @ 2019-08-01 19:23:52
```c
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
string s[25]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
int ss[25]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
int a[20],k=1,kk=0,kongge=0;
int main()
{
string sentence;
getline(cin,sentence);
transform(sentence.begin(),sentence.end(),sentence.begin(),::tolower);//转换为小写
for(int i=0; i<sentence.size(); i++)
{
if(sentence[i]=='.') //已经查找结束
break;
if(sentence[i]==' ')
{
kongge++;
for(int j=0; j<20; j++)//查找该单词是否是数字
{
if(kongge==1)
{
if(sentence.substr(0,k)==s[j])//是数字就对应转换
{
a[kk]=ss[j];//转换为数字
kk++;
k=1;
break;
}
}
else
{
if(sentence.substr(i-k-1,k)==s[j])//是数字就对应转换
{
a[kk]=ss[j];//转换为数字
kk++;
k=1;
break;
}
}
}
}
k++;
}
sort(a,a+kk);//从小到大排序
for(int i=0; i<kk; i++) //输出
if(a[i]!=0)
{
if(a[i]<10)
cout<<0<<a[i];
else
cout<<a[i];
}
cout<<endl;
return 0;
}
```
===================================
改成这样了 但是还是不对 但是结果还是跟原来一样的
by 丸子粥 @ 2019-08-01 19:31:35
最好改成long long
by gx123 @ 2019-08-12 12:54:42
我就是用int然后就80
by gx123 @ 2019-08-12 12:55:12
**~~*开头去0*~~**
by jijidawang @ 2019-12-07 17:31:39