|
发表于 2007-10-16 19:35:00
|
显示全部楼层
Re:小C我的一个关于C++的编程题,有兴趣的可以来看看
template <class T>
T maxn(const T a[],const int b)
{
T max = a[0];
for(int i = 0 ; i<b ; ++i)
{
if(max<a)max = a;
}
return max;
}
char *maxn( char *c[] , int b)
{
size_t max = strlen(c[0]);
char *pt = NULL;
for(int i = 0 ; i<b ; ++i)
{
if(max < strlen(c))pt = c;
}
return pt;
}
int _tmain(int argc, _TCHAR* argv[])
{
int _int[6]={1,6,8,7,5,3,};
double _double[4]={1.21,4.25,3.444,8.22};
char *c[5] = {"CHINA","KOREAN","JAPAN","意大利","米兰"};
cout<<maxn(_int,6)<<endl;
cout<<maxn(_double,4)<<endl;
cout<<maxn(c,5)<<endl;
getch();
return 0;
} |
|