本文共 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/