#include
int main()
{
int a, b, i, t;
int k = 0, sum = 0;
scanf("%d", &a); //輸入整數a
t = a;
if(a / 10 == 0)
k = 1;
sum = a;
printf("%d\n", k);
printf("%d\n", sum);
}
else
while(a / 10 != 0)
a = a / 10; //每除10,就有一位
k++;
printf("%d\n", k+1); //輸出整數的位數
for(i = 0; i
b= t % 10;
sum += b;
t = t / 10;
printf("%d\n", sum); //輸出各位數的和
return 0;
#include
int main()
{
int a, b, i, t;
int k = 0, sum = 0;
scanf("%d", &a); //輸入整數a
t = a;
if(a / 10 == 0)
{
k = 1;
sum = a;
printf("%d\n", k);
printf("%d\n", sum);
}
else
{
while(a / 10 != 0)
{
a = a / 10; //每除10,就有一位
k++;
}
printf("%d\n", k+1); //輸出整數的位數
for(i = 0; i
{
b= t % 10;
sum += b;
t = t / 10;
}
printf("%d\n", sum); //輸出各位數的和
}
return 0;
}