fork download
  1. #include <stdio.h>
  2. int fan(int n){
  3.  
  4. int h,k=10;
  5. int count=0;
  6.  
  7. do{
  8.  
  9. h = n%k;
  10. k=k*10;
  11. count ++;
  12.  
  13. }while(h == 0);
  14.  
  15. int sum,i,e,j=10,t;
  16.  
  17. for(i=0; i<(count-1); i++){
  18.  
  19. j=j*10;
  20.  
  21. }
  22.  
  23. for(i=0; i<(count-1); i++){
  24.  
  25. t = e;
  26. e = n%j;
  27. sum += t;
  28. n -= e*j;
  29. j = j/10;
  30.  
  31. }
  32.  
  33. return sum;
  34.  
  35. }
  36.  
  37. int main(void) {
  38. int f;
  39. scanf("%d" ,&f);
  40. printf("%d" ,fan(f));
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 5316KB
stdin
345
stdout
Standard output is empty