#include <stdio.h> #include <math.h> int main() { int n,i=1,k,s=0,sum=0; printf("input n:\n"); scanf("%d",&n); while(n>0){ k=n*i; n--; s=s+k; i=i*10; }//例如n=3得到了123 //printf("%d",s); do { sum=sum+s; s=s/10; }while(s!=0); printf("%d",sum); return 0; }