rsum.cpp
来自「data structures, algorithms and Applicat」· C++ 代码 · 共 18 行
CPP
18 行
// recursive sum of n numbers
#include <iostream.h>
template<class T>
T Rsum(T a[], int n)
{// Return sum of numbers a[0:n - 1].
if (n > 0)
return Rsum(a, n-1) + a[n-1];
return 0;
}
void main(void)
{
int a[6] = {1, 2, 3, 4, 5, 6};
cout << Rsum(a,6) << endl;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?