HDU 1001 【记第一篇】

很久没有做杭电了,因为代码一直很烂,所以决定从简单的开始,一步步啦~

这是1001题的代码,这道题就是一个累加,用一个循环就可以搞定了~

 1 #include <stdio.h>
 2 #include <stdlib.h>
 3 
 4 int main(void){
 5     int n;
 6      int i , sum ;
 7 
 8     while(scanf("%d",&n)!=EOF){
 9         sum = 0 ;
10         for(i = 1;i <= n; i++){
11             sum = sum+i;
12         }
13         printf("%d

",sum);
14     }
15 }
Everything will be ok in the end. If it is not ok then it is not the end.
原文地址:https://www.cnblogs.com/shirleytian/p/3195165.html