The first T function 6304 4:42 AM

xiaoxiao2021-03-06  48

The first T function #include

#include "stdlib.h"

#include

Using Namespace Std; Template

T CO (T A [], INT N);

Template <> char * co (char * a [], int y);

int main ()

{

INT D [5] = {50, 10, 28, 5, 100};

Int P;

P = CO (D, 5);

Cout << p << "/ n";

Char * DD [5] = {"lbsjs", "jkdjkalssdjkljkl", "jkkj", "lihui", "gougou"}

Char * dw = CO (DD, 5);

COUT << DW << "/ n";

System ("pause");

Return 0;

}

Template

T CO (T A [], INT N)

{

T u;

u = a [0];

For (INT I = 1; I

{

IF (a [i]> u)

u = a [i];

}

Return U;

}

Template <> char * co (char * a [], int y)

{

INT Q, B;

Q = Strlen (a [0]) 1;

For (INT I = 1; I

{

B = Strlen (a [i]) 1;

IF (b> q)

Q = B;

}

For (int i = 0; i

{

IF (Strlen (a [i]) 1 == Q)

Return a [i];

}

}

转载请注明原文地址:https://www.9cbs.com/read-117515.html

New Post(0)