博客
关于我
C++面向对象程序设计 027:简单的SumArray ---- (北大Mooc) (麻了 今天一天嗯是上课没跑成)
阅读量:183 次
发布时间:2019-02-28

本文共 570 字,大约阅读时间需要 1 分钟。

文章目录


专题博客链接


原题题目

在这里插入图片描述

#include 
#include
using namespace std;template
T SumArray(// 在此处补充你的代码}int main() { string array[4] = { "Tom","Jack","Mary","John"}; cout << SumArray(array,array+4) << endl; int a[4] = { 1, 2, 3, 4}; //提示:1+2+3+4 = 10 cout << SumArray(a,a+4) << endl; return 0;}

代码实现

没搞懂什么叫不能编写SumPrint函数 😦

// 在此处补充你的代码T* a,T* b){       int tempcount = 0;    T* temp;    T ret;    for(temp = a;temp != b;temp++,tempcount++)    {           if(!tempcount)  ret= *temp;        else    ret = ret + *temp;    }    return ret;

转载地址:http://runi.baihongyu.com/

你可能感兴趣的文章
netty php,netty
查看>>
Netty WebSocket客户端
查看>>
netty 主要组件+黏包半包+rpc框架+源码透析
查看>>
Vue过渡 & 动画---vue工作笔记0014
查看>>
Netty 异步任务调度与异步线程池
查看>>
Netty 的 Handler 链调用机制
查看>>
Netty 编解码器和 Handler 调用机制
查看>>
Netty 编解码器详解
查看>>
Netty 解决TCP粘包/半包使用
查看>>
Netty 调用,效率这么低还用啥?
查看>>
Netty 高性能架构设计
查看>>
Netty+Protostuff实现单机压测秒级接收35万个对象实践经验分享
查看>>
Netty+SpringBoot+FastDFS+Html5实现聊天App详解(一)
查看>>
netty--helloword程序
查看>>
netty2---服务端和客户端
查看>>
【Flink】Flink 2023 Flink易用性和稳定性在Shopee的优化-视频笔记
查看>>
Netty5.x 和3.x、4.x的区别及注意事项(官方翻译)
查看>>
netty——bytebuf的创建、内存分配与池化、组成、扩容规则、写入读取、内存回收、零拷贝
查看>>
netty——Channl的常用方法、ChannelFuture、CloseFuture
查看>>
netty——EventLoop概念、处理普通任务定时任务、处理io事件、EventLoopGroup
查看>>