-->
当前位置:首页 > 题库

函数题:Sum 1-n

Luz4年前 (2022-04-24)题库740
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






答案:若无答案欢迎评论