-->
当前位置:首页 > 题库 > 正文内容

函数题:Sum 1-n

Luz3年前 (2022-04-24)题库622
Write a function to calculate the sum of 1 - n.
### function declaration:
c++
int sum ( int n );


### Test code:
c++
#include <stdio.h>
int sum (int n);
int main()
{
int n;
scanf("%d", &n);
printf("%d", sum(n));
return 0;
}

/* Your answer will be put here */


### Input sample:

5


### Output sample:

15






答案:若无答案欢迎评论

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。