tempcomp.h
来自「一本语言类编程书籍」· C头文件 代码 · 共 21 行
H
21 行
// tempcomp.h
namespace compare {
// Function template to find the maximum element in an array
template<class T> T max(const T* data, int size) {
T result = data[0];
for(int i = 1 ; i < size ; i++)
if(result < data[i])
result = data[i];
return result;
}
// Function template to find the minimum element in an array
template<class T> T min(const T* data, int size) {
T result = data[0];
for(int i = 1 ; i < size ; i++)
if(result > data[i])
result = data[i];
return result;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?