题意就是给你一串数字,让你求他们的和,然后用英文表示出来。
因为最大是10的100次方,超过了long long,所以用字符串表示,模拟手算方式。
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define INF 0x3fffffff
using namespace std;
int main()
{
char s[10][10]={"zero","one","two","three","four","five","six","seven","eight","nine"};
char a[105];
int b[105],maxl=0;
memset(b,0,sizeof(b));
cin>>a;
for (int i=0;i<strlen(a);i++)
{
int j=0;
b[j]=b[j]+(a[i]-'0');
while (b[j]>9)
{
b[j+1]=b[j+1]+1;
b[j]=b[j]%10;
j++;
if (j>maxl)
maxl=j;
}
}
for (int i=maxl;i>0;i--)
cout<<s[b[i]]<<' ';
cout<<s[b[0]];
}