hdu1013

 1 #include <stdio.h>
 2 #include <string.h>
 3 /*
 4 int fuc(int n){
 5     if(n%9==0) return 9;
 6     else    return n%9;
 7 }
 8 */
 9 
10 int fuc(int n){
11     return (n-1)%9+1;
12 }
13 
14 int main(){
15     int n,l,i;
16     char str[10000];
17     while(scanf("%s",&str)&&str[0]!='0'){
18         n=0;
19         l=strlen(str);
20         for(i=0;i<l;++i)    n+=str[i]-'0';
21         printf("%d
",fuc(n));
22 
23     }
24     return 0;
25 }
原文地址:https://www.cnblogs.com/symons1992/p/3301446.html