PAT1005. Spell It Right (20)
来源:互联网 发布:俄罗斯方舟 知乎 编辑:程序博客网 时间:2024/06/06 03:23
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1005
对于大数N (<= 10^100)的处理,考虑使用字符串。
代码如下:
#include<map>#include<string>#include<iostream>#include<vector>#include<string.h>#include<algorithm>#include<stdlib.h>#include<stdio.h>#include<set>using namespace std;int main(){string numE[10]={"zero","one","two","three","four","five","six","seven","eight","nine"};int i;map<char,int>m;for(i=0;i<=9;i++)m['0'+i]=i;string str;cin>>str;int sum=0;for(i=0;i<str.length();i++)sum+=m[str[i]];char c[10000];string strSum;sprintf(c,"%d",sum);strSum=c;for(i=0;i<strSum.length();i++){int temp=strSum[i]-48;if(i!=strSum.length()-1)cout<<numE[temp]<<" ";elsecout<<numE[temp]<<endl;}return 0;}
- PAT1005. Spell It Right (20)
- PAT1005. Spell It Right (20)
- PAT1005. Spell It Right (20)
- PAT1005. Spell It Right (20)
- PAT1005. Spell It Right (20)
- PAT1005.Spell It Right
- PAT1005. Spell It Right
- pat1005 Spell It Right
- PAT1005-Spell It Right
- PAT1005 Spell It Right 大水题
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005 Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- 1005. Spell It Right (20)
- spring和hibernate的一个整合
- LINUX下动态链接库的使用-dlopen dlsym dlclose dlerror
- 析构函数的使用
- 如何将C/C++程序转译成Delphi(五)
- 【rzxt】如何修改Win7资源管理器默认路径
- PAT1005. Spell It Right (20)
- oracle 查看用户表数目,表大小,视图数目等
- 【rzxt】玩转Win7文件库 让文件"消失"
- WebGL自学课程(14):WebGL使用Mipmap纹理
- Ext中下拉列表ComboBox组件store数据格式
- 安装Microsoft Windows SDK 7.1时出现的错误(附解决办法)
- Android 颜色对照表
- VS项目属性中没有链接器选项
- HTTP中的新鲜度