PAT 甲级 1005 Spell It Right
发布日期:2021-07-01 03:08:44 浏览次数:2 分类:技术文章

本文共 1575 字,大约阅读时间需要 5 分钟。

1005 Spell It Right (20 point(s))

Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.

Input Specification:

Each input file contains one test case. Each case occupies one line which contains an N (≤10​100​​).

Output Specification:

For each test case, output in one line the digits of the sum in English words. There must be one space between two consecutive words, but no extra space at the end of a line.

Sample Input:

12345

Sample Output:

one five

Experiential Summing-up

emmmmm, this question is pretty easy. Everybody knows~  So I don't introduce something about it~

(The purpose of using English to portray my solution is that to exercise the ability of my expression of English and accommodate PAT advanced level's style.We can make progress together by reading and comprehending it. Please forgive my basic grammar's and word's error. Of course, I would appreciated it if you can point out my grammar's and word's error in comment section.( •̀∀•́ ) Furthermore, Big Lao please don't laugh at me because I just a English beginner settle for CET6    _(:з」∠)_  )

Accepted Code 

#include 
#include
const int maxn=110;int main(){ int m,n,k,no,t; char str[maxn],s[maxn]; char ans[10][8]={"zero","one","two","three","four","five","six","seven","eight","nine"}; scanf("%s",str); int sum=0; for(int i=0;str[i]!='\0';++i) { sum+=str[i]-'0'; } sprintf(s,"%d",sum); for(int i=0;s[i]!='\0';++i) { printf("%s",ans[s[i]-'0']); if(s[i+1]!='\0') printf(" "); else printf("\n"); } return 0;}

 

转载地址:https://meteorrain.blog.csdn.net/article/details/86515421 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:PAT 甲级 1006 Sign In and Sign Out
下一篇:PAT 甲级 1004 Counting Leaves

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月19日 10时24分00秒