// 字符串处理 ------------------------------------------
Sample Input:
12345
Sample Output:
one five.
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
char a[20], s[20];
gets(a);
int sum = 0;
for(int i=0; i<strlen(a); i++) sum += (a[i] - '0');
sprintf(s,"%d",sum);
char arr[10][10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
for(int i=0; i<strlen(s); i++) printf("%s ",arr[s[i] - '0']);
return 0;
}
字符串处理
最新推荐文章于 2024-06-22 23:01:55 发布