Zju 2971 Give Me the Number不再困惑
来源:互联网 发布:阿里云怎么下网站模板 编辑:程序博客网 时间:2024/05/18 00:08
本题思路简单,先构造出1000以内的英文数字表示放在string数组d000中,然后把10^9内的数字分成3段各1000以内的串s3,s2,s1,然后取得对应的d000下标p3,p2,p1,用p3*1000000+p2*1000+p1得到结果。其中把10^9内的数字分成3段的函数split用substr得到错误“Restricted Function”。郁闷了好久!
终于知道问题所在!Zju 2971 Give Me the Number不再困惑了。原来是用substr时要用注意起始位置参数要小于串长,长度参数的值必须>0。注意类似于one thousand的测试数据。下面是我的分隔函数。
void split(string t, string &s3, string &s2, string &s1)
...{
int i=t.find(" million");
if (i!=-1)
...{
s3=t.substr(0,i);
if (i+9<t.size()) t=t.substr(i+9);
}
int j=t.find(" thousand");
if (j!=-1)
...{
s2=t.substr(0,j);
if (j+10<t.size()) t=t.substr(j+10);
}
s1=t;
}
...{
int i=t.find(" million");
if (i!=-1)
...{
s3=t.substr(0,i);
if (i+9<t.size()) t=t.substr(i+9);
}
int j=t.find(" thousand");
if (j!=-1)
...{
s2=t.substr(0,j);
if (j+10<t.size()) t=t.substr(j+10);
}
s1=t;
}
- Zju 2971 Give Me the Number不再困惑
- give me the number
- ZOJ - 2971 Give Me the Number 模拟
- zoj 2971 Give Me the Number
- poj 2971 Give Me the Number
- zoj 2971 Give Me the Number
- ZOJ 2971 Give Me the Number
- ZOJ 2971 Give Me the Number
- ZOJ - 2971 Give Me the Number
- ZOJ 2971 Give Me the Number
- ZOJ 2971 Give Me the Number
- ZOJ 2971Give Me the Number
- ZOJ2971-Give Me the Number
- [英文转数字]ZOJ 2971 Give Me the Number
- zoj 2971 Give Me the Number (模拟)
- ZOJ 2971 && HNUOJ 16490 Give Me the Number
- ZOJ 2971-G - Give Me the Number-模拟
- ZOJ 2971 Give Me the Number(模拟)
- 最先进的技术:Windows Workflow Foundation
- linux驱动指南
- 完美结束EXCEL进程
- RegularExpressionDemo.java
- 逻辑代码与呈现代码分离原则
- Zju 2971 Give Me the Number不再困惑
- fedora8 无法上网
- 用Boost.Python构建混合系统
- 在JVM退出的时候,执行一段特定的代码。
- Win32 二进制资源格式(全)
- 打印局部页面
- 图解Web2.0
- C#面向对象分析
- APUE阅读笔记:Chapter 15 IPC