1005 Spell It Right
程序员文章站
2022-06-11 16:12:49
...
题目大意:
给你一个数n,计算每一位和相加后的结果,输出英文形式(神特么英文形式。。)
解题思路:
水题,模拟即可。
代码如下:
#include<iostream>
#include<cstdio>
#include<fstream>
#include<set>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<vector>
#include<iomanip>
#include<cstdlib>
#include<list>
#include<queue>
#include<stack>
#include<algorithm>
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define meminf(a) memset(a,inf,sizeof(a))
//vector ::iterator it;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
string judge(int t)
{
if(t==0)return "zero";
else if(t==1)return "one";
else if(t==2)return "two";
else if(t==3)return "three";
else if(t==4)return "four";
else if(t==5)return "five";
else if(t==6)return "six";
else if(t==7)return "seven";
else if(t==8)return "eight";
else if(t==9)return "nine";
}
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
char a[1000]={0};
cin>>a;
int len=strlen(a),sum=0;
for(int i=0;i<len;i++)
{
int t=a[i]-'0';
sum+=t;
}
if(sum<10)cout<<judge(sum)<<endl;
else if(sum>=10&&sum<100)
cout<<judge(sum/10)<<' '<<judge(sum%10)<<endl;
else if(sum>=100)
cout<<judge(sum/100)<<' '<<judge(sum/10%10)<<' '<<judge(sum%10)<<endl;
return 0;
//freopen("test.txt","r",stdin);
// freopen("output.txt","w",stdout);
}
上一篇: ASP.net泛型list常用操作
推荐阅读
-
sql的left join 、right join 、inner join之间的区别
-
数据库Left join , Right Join, Inner Join 的相关内容,非常实用
-
惠普M1005打印机怎么安装墨盒?
-
惠普hp1005打印机怎么扫描纸质文件?
-
解析mysql left( right ) join使用on与where筛选的差异
-
SQL中的left join right join
-
超详细mysql left join,right join,inner join用法分析
-
HP惠普M1005打印机不能扫描文件该怎么办?
-
惠普1005黑白激光打印机一台怎么设置?
-
oracle中left join和right join的区别浅谈