oj--pat--b1002
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oj--pat--b1002相关的知识,希望对你有一定的参考价值。
#include<cstdio> #include<cstring>//memset char str[105]; int outstr[50]; char map[11][5]={"ling","yi","er","san","si","wu","liu","qi","ba","jiu","shi"}; int main(){ while(scanf("%s",str)!=EOF){ int sum=0; for(int i=0;str[i]!=‘\0‘;i++){ //Here 0 is equal to ‘\0‘. sum+=str[i]-‘0‘; } memset(str,0,sizeof(str)); int pos=0; while(sum!=0){ outstr[pos++]=sum%10; sum/=10; } for(int i=pos-1;i>=0;i--){ int t=outstr[i]; if(i==pos-1) printf("%s",map[t]);//t is the row index.map[t] is not equal to map[t][]. else printf(" %s",map[t]); } } return 0; }
以上是关于oj--pat--b1002的主要内容,如果未能解决你的问题,请参考以下文章