| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么要开数组呢直接加起来就好了,呵呵O(∩_∩)O~
#include<cstdio>
int main()
{
int ans=0;
char ch=0;
while(scanf("%c",&ch)!=EOF)
{
if(ch=='\n')
{
if(ans==0)break;
ans%=9;
if(ans!=0)printf("%d\n",ans);
else printf("9\n");
ans=0;
}
else ans+=(ch-'0');
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator