#include <stdio.h> int fun(int x,int &sum) { while(x) { sum=x%10+sum; x=x/10; } return 0; } int main() { int x,sum=0; scanf("%d",&x); fun(x,sum); printf("%d\n",sum); return 0; }
#include <stdio.h> int fun(int x,int &sum) { while(x) { sum=x%10+sum; x=x/10; } return 0; } int main() { int x,sum=0; scanf("%d",&x); fun(x,sum); printf("%d\n",sum); return 0; }
转载于:https://www.cnblogs.com/bonke/archive/2013/05/08/3066774.html