第1个回答 2016-06-03
#include "stdio.h"
int main(void){
int n;
while(printf("n = "),scanf("%d",&n) && n>0)
printf("The result is %d\n",n*(n+1)/2);
return 0;
}本回答被网友采纳
第2个回答 2016-06-03
#include<stdio.h>
int main(){
int n,i;
while(scanf("%d",&n)){
if(n==-1)
break;
int sum=0;
for(i=1;i<=n;i++)
sum+=i;
printf("%d\n",sum);
}
return 0;
}