内核调试器!devnode中ResourceList、Translated与BootResources解析
2026/10/10 14:43:26
作者 xiesonghua
单位 武汉理工大学
设计一个函数模板Sum(指针,数组大小),将不同数据类型数组中的元素求和。
#include <iostream> using namespace std; int main() { int int_array[10],i; for(i=0;i<10;i++) cin>>int_array[i]; double double_array[]={1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9,10.01}; cout<<"The summary of integer array:"<<Sum(int_array,10)<<endl; cout<<"The summary of double array:"<<Sum(double_array,10)<<endl; return 0; } /* 请在这里填写答案 */1 3 5 7 9 11 13 15 17 19The summary of integer array:100 the summary of double array:59.51参考示例 :
template<typename T> T Sum(T *arr,int n){ T s=0; for(int i=0;i<n;i++)s+=arr[i]; return s; }