[恢]hdu 2162

2011-12-15 02:43:48

地址:http://acm.hdu.edu.cn/showproblem.php?pid=2162

题意:输入一堆数,求和。

代码:

# include <stdio.h>


int main ()
{
int n, sum, num ;
int nCase = 1 ;
while (~scanf ("%d", &n) && n > 0)
{
sum = 0 ;
while (n--)
{
scanf ("%d", &num) ;
sum += num ;
}
printf ("Sum of #%d is %d\n", nCase++, sum) ;
}
return 0 ;
}



posted @ 2012-01-06 15:02  Seraph2012  阅读(107)  评论(0编辑  收藏  举报