Get The Sum

来源:互联网 发布:java p2p项目视频下载 编辑:程序博客网 时间:2024/05/21 12:48

Get The Sum

Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

 Now you have got an task of calculating the sum of integers between 1 and N inclusively.

输入

 The first line of input is an integer T (0 < T ≤ 100),which means there are T test cases.The next following T lines contains T integers,each in a separate line.The absolute value of N is no more than 10000.

输出

 For each test case,output the sum of integers between 1 and N inclusively.

示例输入

312-3

示例输出

13-5

提示

 

来源

 

示例程序

 
#include<stdio.h>  int main()  {      int i,j,n,m,a[100];      scanf("%d",&n);      for(i=0;i<n;i++)      {          m=0;          scanf("%d",&a[i]);          if(a[i]>0)      for(j=a[i];j>=1;j--)      {          m+=j;      }      else      for(j=a[i];j<=1;j++)      {          m+=j;      }      printf("%d\n",m);      }  } 

0 0