NYOJ 105 9的余数

http://acm.nyist.net/JudgeOnline/problem.php?pid=105

 

 1  
 2 #include<stdio.h>
 3 #include<string.h>
 4 
 5 int main()
 6 { 
 7 int T,s;
 8 scanf("%d",&T);
 9 while(T--)
10 {
11     char a[1100000];
12     int i,sum=0,m;
13     scanf("%s",a);
14     m=strlen(a);
15     for(i=0;i<m;i++)
16     sum+=(a[i]-'0');
17     s=sum%9;
18     printf("%d\n",s);
19 }
20 return 0;
21 }
22         

 

posted @ 2013-08-21 15:02  hpu张亚飞  阅读(169)  评论(0)    收藏  举报