回复 19楼 lin5161678
谢谢啦
#include<stdio.h> int main(){ int a; scanf("%d",&a); int t=0; while(a!=0){ t+=a%10; a/=10; } int cnt=0; while(t!=0){ t/=10; cnt+=1; } printf("%d",cnt); return 0; }
#include <stdio.h> int main() { int num, sum=0, count=0; printf("输入一个整数:"); scanf("%d", &num); while (num>0) { sum+=num%10; count++; num=(num-num%10)/10; } printf("位数:%d\n", count); printf("各位之和:%d\n", sum); return 0; }