#include <iostream>???????????????????????????????? // 預(yù)處理命令???????????????????????????????????? //2using namespace std;???????????????????????? ?????? // 使用標(biāo)準(zhǔn)命名空間std????????????????????? //3?????????????????????????????????????????????????????????????????????????????????????????????????????????????????? //4template <class ElemType>???????????????????????????????????????????? ?????????????????????????????????? //5ElemType Max(ElemType a, ElemType b)???? // 返回最大值???????????????????????????????????? //6{???????????????????????????????????????????????????????????????????????????????????????????????????????????????? //7?? return (a > b) ? a : b;??????????????? ?????? // 返回a與b的最大值???????????????????????? //8}???????????????????????????????????????????????????????????????????????????????????????????????????????????????? //9?????????????????????????????????????????????????????????????????????????????????????????????????????????????????? //11int main(void)???????????????????????????????????? ?????? // 主函數(shù)main(void)????????????????????????? //12{???????????????????????????????????????????????????????????????????????????????????????????????????????????????? //13?? cout << Max(16, 518) << endl;?????? ?????? // 顯示最大值???????????????????????????????????? //14?? cout << Max(16.8, 518) << endl;??? // 顯示最大值???????????????????????????????????? //15?????????????????????????????????????????????????????????????????????????????????????????????????????????????????? //16?? system("PAUSE");????????????? // 調(diào)用庫(kù)函數(shù)system( ), 輸出系統(tǒng)提示信息? ?????? ?????? //17?????? return 0;
1 回答

asd8532
TA貢獻(xiàn)143條經(jīng)驗(yàn) 獲得超187個(gè)贊
cout?<<?Max<int>(16,?518)?<<?endl;??????????????//?函數(shù)模板要加<>,里面要填上類型才可以的?????????????????????????????? cout?<<?Max<double>(16.8,?518)?<<?endl;
- 1 回答
- 0 關(guān)注
- 1285 瀏覽
添加回答
舉報(bào)
0/150
提交
取消