PAT甲级真题1005. Spell It Right

题目链接:https://www.patest.cn/contests/pat-a-practise/1005

PAT甲级真题1005. Spell It Right_第1张图片

题意非常的简单,给我们一个数,让我们把这个数所有位上的数加起来,得到的和通过英文把每一位读出来。

这题需要注意的是N的范围是10^100,所以我们不能通过int,甚至是long long来读入,这里我们应该按照字符串进行读入。

#include 
#include 
#include 
#include 
using namespace std;
const int maxn = 100+5;
char str[maxn];
int a[1000+5];
char s[10][10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
int main() {
	scanf("%s", str);
	int num = 0;
	for(int i=0; i=0; i--) {
		printf("%s", s[a[i]]);
		if(i == 0) {
			printf("\n");
		}
		else {
			printf(" ");
		}
	}
}

你可能感兴趣的:(ACM_Water,PAT考题练习题解)