第1个回答 2009-10-12
#include <stdio.h>
int main()
{
int num = 0;
int s = 0;
int i = 0;
scanf("%d", &num);
while(num)
{
s += num%10;
num = num/10;
i++;
}
printf("数字个数为%d,各个数相加为%d\n",i, s );
return 0;
}本回答被提问者采纳
第2个回答 2013-03-31
#include <stdio.h>
int main()
{
long num = 0;
long s = 0;
long i = 0;
scanf("%ld", &num);
while(num)
{
s += num%10;
num = num/10;
i++;
}
printf("Number of data items %d,All together%d\n",i, s );
getch();
}