请教 3个数字比大小,怎么找出第二大的数
我的确是,新人。。。
[此贴子已经被作者于2006-3-5 20:51:42编辑过]
#include <iostream>
#include <cstdlib>
using namespace std;
template <class T>
T findMiddleFromThreeNum(T a, T b, T c)
{
if((a>=b && a<=c) || (a>=c && a<=b))
return a;
else if ((b>=a && b<=c) || (b>=c && b<=a))
return b;
else
return c;
}
int main()
{
int a = -20;
int b = 9;
int c = 6;
int middle = findMiddleFromThreeNum(a, b, c);
cout<<middle<<endl; // to see the result;
system(\"pause\");
return 0;
}
#include <iostream>
#include <cstdlib>
using namespace std;
template <class T>
T findMiddleFromThreeNum(T a, T b, T c)
{
if((a>=b && a<=c) || (a>=c && a<=b))
return a;
else if ((b>=a && b<=c) || (b>=c && b<=a))
return b;
else
return c;
}
int main()
{
int a = -20;
int b = 9;
int c = 6;
int middle = findMiddleFromThreeNum(a, b, c);
cout<<middle<<endl; // to see the result;
system(\"pause\");
return 0;
}
好经典的了
简单明了
怎么看不懂啊