怎么优化这个程序
简而言之就是反复对一个数n的各位求和,直到结果小于10,n在int类型内#include<stdio.h>
int main(void)
{
int a,b,c,d,e,f,g,h,i,j,n,m;
scanf("%d",&n);
if(n>=10)
{
for(;n>=10;)
{
a=n/1000000000;
b=(n-a*1000000000)/100000000;
c=(n-a*1000000000-b*100000000)/10000000;
d=(n-a*1000000000-b*100000000-c*10000000)/1000000;
e=(n-a*1000000000-b*100000000-c*10000000-d*1000000)/100000;
f=(n-a*1000000000-b*100000000-c*10000000-d*1000000-e*100000)/10000;
g=(n-a*1000000000-b*100000000-c*10000000-d*1000000-e*100000-f*10000)/1000;
h=(n-a*1000000000-b*100000000-c*10000000-d*1000000-e*100000-f*10000-g*1000)/100;
i=(n-a*1000000000-b*100000000-c*10000000-d*1000000-e*100000-f*10000-g*1000-h*100)/10;
j=(n-a*1000000000-b*100000000-c*10000000-d*1000000-e*100000-f*10000-g*1000-h*100-i*10);
m=a+b+c+d+e+f+g+h+i+j;
n=m;
}
printf("%d",m);
}
else
printf("%d",n);
}
(另:怎么进行结帖操作)