C++ 函数与数组
2024-09-08 16:59:03
C++ 函数与数组
#include<iostream>
using namespace std;
const int ArSize = 8;
int sum_arr(int arr[], int n);
int main() {
int cookies[ArSize]{ 1,2,4,8,16,32,64,128 };
int sum = sum_arr(cookies, ArSize);
cout << "Total cookies eaten:" << sum << "\n";
return 0;
}
int sum_arr(int arr[], int n) {
int total = 0;
for (int i = 0; i < n; i++)
total = total + arr[i];
return total;
}
最新文章
- ASP.NET Core中的依赖注入(5):ServicePrvider实现揭秘【补充漏掉的细节】
- tp框架之数据添加
- archlinux 传统方法编译内核linux kernel 3.3.7
- log4js
- Android listview.item.clear()与listview.clear()的区别
- 一步一步学习SignalR进行实时通信_8_案例2
- 算法导论(第三版)Exercises2.1(插入排序、线性查找、N位大数相加)
- Android设计中的.9.png与Android Studio中的设置
- New UWP Community Toolkit - ImageEx
- python pymysql.err.InternalError: (1366, ";Incorrect string value: &#39;\\xE9\\x9F\\xA9\\xE6\\xA2\\x85...
- C#windows桌面应用小程序制作——大文件数据分段解析存储
- 深入理解JVM(2)——揭开HotSpot对象创建的奥秘
- 配置iis支持json解析,配置ssi
- 初学c# -- c#创建开机自启服调用外部交互式exe文件
- transition,过渡效果
- 项目部署到liunx环境下访问接口返回异常
- bzoj1227 P2154 [SDOI2009]虔诚的墓主人
- Java 根据出生日期计算年龄
- PyCharm 配置远程python解释器
- vss整合配置连接到Myeclipse中以及中文配置