zju1115
Digital Roots
http://acm.zju.edu.cn/show_problem.php?pid=1115
/*written by czk*/
#include <stdio.h>
#include <ctype.h>
int main() {
while(1) {
int sum = 0;
char c;
while(!isdigit(c=getchar()));
if(c=='0') break;
while(isdigit(c)) {
sum+= (c-'0');
c = getchar();
}
while(sum >= 10) {
int temp = sum;
sum = 0;
while(temp>0) {
sum += temp %10;
temp /= 10;
}
}
printf("%d\n", sum);
}
}