symons

___________每一天都是幸福的!!

  博客园  ::  :: 新随笔  ::  :: 订阅 订阅  :: 管理
 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\n",fuc(n));
22 
23     }
24     return 0;
25 }

 

posted on 2013-09-04 17:30  symons  阅读(323)  评论(0编辑  收藏  举报