当前位置:网站首页>实现一个计算m~n(m<n)之间所有整数的和的简单函数
实现一个计算m~n(m<n)之间所有整数的和的简单函数
2022-04-23 05:46:00 【OceanKeeper1215】
函数接口定义:
int sum( int m, int n );
裁判测试程序样例:
#include <stdio.h>
int sum(int m, int n);
int main()
{
int m, n;
scanf("%d %d", &m, &n);
printf("sum = %d\n", sum(m, n));
return 0;
}
/* 你的代码将被嵌在这里 */
输入样例:
-5 8
输出样例:
sum = 21
我的答案:
int sum(int m,int n)
{
int he;
for(m,n;m<=n;m++){
he=he+m;
}
return he;
}
版权声明
本文为[OceanKeeper1215]所创,转载请带上原文链接,感谢
https://blog.csdn.net/OceanKeeper1215/article/details/118963194
边栏推荐
- [leetcode 67] sum of two binary numbers
- Explanation of the second I interval of 2020 Niuke summer multi school training camp
- Usage scenario of copyonwritearraylist
- SQL -- data definition
- C language file operation
- Rust 中的 Cell 共享可变指针
- A solution to replace not in in SQL
- 5.The Simple Problem
- Kibana search syntax
- 安全授信
猜你喜欢
Robocode教程4——Robocode的游戏物理
Solution to the trial of ycu Blue Bridge Cup programming competition in 2021
Database - sorting data
Mysql database foundation
SQL -- data filtering and grouping
Explanation of login page
How SYSTEMd uses / etc / init D script
MySQL table constraints and table design
Installation and usage skills of idea
Addition, deletion, modification and query of MySQL table
随机推荐
Log4j2跨线程打印traceId
Basic knowledge of network in cloud computing
[leetcode 202] happy number
LockSupport. Park and unpark, wait and notify
POJ - 2955 brackets interval DP
Linux 用rpm的方式安装mysql(超简单)
Arcpy为矢量数据添加字段与循环赋值
Excel打开超大csv格式数据
Substring Inversion (Easy Version)
SVN简单操作命令
Rust 中的 RefCell
日志
Example of ticket selling with reentrant lock
小区房价可视化
Common sense of thread pool
多线程爬取马可波罗网供应商数据
Integers have friends interval GCD + double pointer
[leetcode 383] ransom letter
用二进制进行权限管理
Event listener