首页 > 代码库 > oj--pat--b1002
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。