codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <cstdlib> #include <iostream> /// template <typename T> T func_max(T arr[], int count) { T Res = arr[0]; for(int i = 0; i < count; ++i) if(arr[i] > Res) Res = arr[i]; return Res; } template <> const char *func_max(const char *cArr[], int count) { const char *Res = cArr[0]; for(int i = 0; i < count; ++i) if(strlen(Res) < strlen(cArr[i])) Res = cArr[i]; return Res; } int main(int argc, char *argv[]) { int mass1[6] = { 5, 90, 3, 2, 9, 7 }; double mass2[4] = { 4.8, 8.0, 5.3, 3.14}; const char *mchar[5] = { "Dasha", "InokentyW", "Jora", "Tanyasdw", "IrinaW" }; std::cout << func_max(mass1,6) << std::endl; std::cout << func_max(mass2,4) << std::endl; std::cout << func_max(mchar,5) << std::endl; system("PAUSE"); return EXIT_SUCCESS; }
Private
[
?
]
Run code
Submit