poj 英语数字转换器 编程问题求解答

#include
#include
#include
#include
#include
#include
#include
using namespace std;
map reff;
int main()
{
reff["zero"] = 0; reff["one"] = 1; reff["two"] = 2;
reff["three"] = 3; reff["four"] = 4; reff["five"] = 5;
reff["six"] = 6; reff["seven"] = 7; reff["eight"] = 8;
reff["nine"] = 9; reff["ten"] = 10; reff["eleven"] = 11;
reff["twelve"] = 12; reff["thirteen"] = 13; reff["fourteen"] = 14;
reff["fifteen"] = 15; reff["sixteen"] = 16; reff["seventeen"] = 17;
reff["eighteen"] = 18; reff["nineteen"] = 19; reff["twenty"] = 20;
reff["thirty"] = 30; reff["forty"] = 40; reff["fifty"] = 50;
reff["sixty"] = 60; reff["seventy"] = 70; reff["eighty"] = 80;
reff["ninety"] = 90; reff["hundred"] = 100; reff["thousand"] = 1000;
reff["million"] = 1000000;
//首先是怎么处理输入?
string a;
while(getline(cin,a))
{
string s;
long res = 0;//存放结果
long res1 = 0;
long cur = 0;//存放暂时的结果
int last = 1000000;//看上一次的千、百、百万单位是什么
int flag = 0;//看是不是负数
queue q;
int i = 0;
while(i {
s = "";
while(a[i]!=' ' && i {
s+=a[i];
i++;
}
q.push(s);//这里没有问题所有的子串都进去了
i++;
}
if(q.front() == "negative")
{
flag = 1;
q.pop();
}
while(!q.empty())
{
cur = reff[q.front()];
if(cur >= 10 && cur <= 100)
{
last = 10;
}
q.pop();
if(cur {
if(reff[q.front()]>=100 && reff[q.front()]<=last)
{
cur = cur * reff[q.front()];
last = reff[q.front()];
q.pop();
res += cur;
if(res > 1000000)
{
res1 = res;
res = 0;
cur = 0;
}
}
else if(reff[q.front()]>=100 && reff[q.front()]>last)
{
res = (res+cur)*reff[q.front()];
last = reff[q.front()];
q.pop();
if(res > 1000000)
{
res1 = res;
res = 0;
cur = 0;
}
}
else
res += cur;
}
else
res += cur;
}
if(a!=" ")
{
if(flag == 0)
cout<<res + res1<<endl;
else
cout<<-(res + res1)<<endl;
}
}
return 0;
}
请问为什么会RE?

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐