求这道c语言编程代码?

2024-11-09 06:00:52
推荐回答(1个)
回答(1):

#include

int main()

{ int n,s=0;

  scanf("%d",&n);

  while(n)s+=n%10,n/=10;

  printf("%d\n",s);

  return 0;

}