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;
}

最新文章

  1. ASP.NET Core中的依赖注入(5):ServicePrvider实现揭秘【补充漏掉的细节】
  2. tp框架之数据添加
  3. archlinux 传统方法编译内核linux kernel 3.3.7
  4. log4js
  5. Android listview.item.clear()与listview.clear()的区别
  6. 一步一步学习SignalR进行实时通信_8_案例2
  7. 算法导论(第三版)Exercises2.1(插入排序、线性查找、N位大数相加)
  8. Android设计中的.9.png与Android Studio中的设置
  9. New UWP Community Toolkit - ImageEx
  10. python pymysql.err.InternalError: (1366, &quot;Incorrect string value: &#39;\\xE9\\x9F\\xA9\\xE6\\xA2\\x85...
  11. C#windows桌面应用小程序制作——大文件数据分段解析存储
  12. 深入理解JVM(2)——揭开HotSpot对象创建的奥秘
  13. 配置iis支持json解析,配置ssi
  14. 初学c# -- c#创建开机自启服调用外部交互式exe文件
  15. transition,过渡效果
  16. 项目部署到liunx环境下访问接口返回异常
  17. bzoj1227 P2154 [SDOI2009]虔诚的墓主人
  18. Java 根据出生日期计算年龄
  19. PyCharm 配置远程python解释器
  20. vss整合配置连接到Myeclipse中以及中文配置

热门文章

  1. 第三周day4
  2. matlab读写文件操作
  3. 日常开发记录-Object函数的内置方法Object.entries
  4. iOS MacOS 系统时间(时间戳)格式化
  5. nginx转发端口路由器再转发
  6. k8s入门_label标签、nodeSelector
  7. pyintaller 打包后报No module named &#39;XXX&#39;
  8. windows服务包装程序
  9. taro+vue3模板-废弃
  10. Vue非父子組件(爺孫關係)通信Provide&amp;&amp;Inject