标签:
// // main.c // TrainingForC // // Created by Deak on 15/8/21. // Copyright (c) 2015年 Shen.Jun. All rights reserved. // #include "stdio.h" #include "math.h" int cnt = 1; int bit (int n) { if (n/10 == 0) { return cnt; } else { cnt++; return bit(n/10); } } void print (int n) { switch (n) { case 0: printf("ling"); break; case 1: printf("yi");break; case 2: printf("er");break; case 3: printf("san");break; case 4: printf("si");break; case 5: printf("wu");break; case 6: printf("liu");break; case 7: printf("qi");break; case 8: printf("ba");break; case 9: printf("jiu");break; } } int mypow(int n) { int ans = 1; for (int i = 0; i < n; i++) { ans *= 10; } return ans; } int main(void) { long long int n = 0,tar = 0; scanf("%lld",&n); printf("%lld",n); int w = bit(n),sum = 0; for (int i = 0; i < w; i++) { sum = sum+n/mypow(i)%10; } cnt = 1; w = bit(sum); for (int i = w; i > 1; i--) { tar = sum/mypow(i-1)%10; print(tar); printf(" "); } print(sum%10); } // #include"stdio.h" int cnt = 1; int bit (int n) { if (n/10 == 0) { return cnt; } else { cnt++; return bit(n/10); } } int mypow(int n) { int ans = 1; for (int i = 0; i < n; i++) { ans *= 10; } return ans; } void print (int n) { switch (n) { case 0: printf("ling"); break; case 1: printf("yi");break; case 2: printf("er");break; case 3: printf("san");break; case 4: printf("si");break; case 5: printf("wu");break; case 6: printf("liu");break; case 7: printf("qi");break; case 8: printf("ba");break; case 9: printf("jiu");break; } } int main(void) { char n[101] = {0}; scanf("%s",&n); int sum = 0; for (int i = 0; i < 100; i++) { if (n[i] != ‘\0‘) { sum += n[i] - ‘0‘; } } int w = 0, tar = 0; w = bit(sum); for (int i = w; i > 1; i--) { tar = sum/mypow(i-1)%10; print(tar); printf(" "); } print(sum%10); }
标签:
原文地址:http://www.cnblogs.com/sjdeak/p/4762511.html