cleey
望着那一丝海线,若隐若现。落日下的海霞,数不尽的美,看不完的醉
hdu1001
目的:计算出1+2+..+n

思路:输入n,计算出1+2+..+n

#include
int sum(int *a){
int sum = 0,i = 1;
for(;i<=*a;i++){sum += i;}
return sum;
}
void main(){
int a;
while(scanf("%d",&a)!=EOF){
printf("%d\n\n",sum(&a));
}
}
<< 上一篇 hdu1000 hdu1089 下一篇 >>
文章标签
随意 | Created At 2014 By William Clinton | 蜀ICP备14002619号-4 |