#include using namespace std;

int min(int a, int b) { return a < b ? a : b; }

float min(float a, float b) { return a < b ? a : b; }

char min(char a, char b) { return a < b ? a : b; }

int main() { int a = 5, b = 3; float c = 4.2, d = 3.8; char e = 'a', f = 'b'; cout << "Min of " << a << " and " << b << " is " << min(a, b) << endl; cout << "Min of " << c << " and " << d << " is " << min(c, d) << endl; cout << "Min of " << e << " and " << f << " is " << min(e, f) << endl; return 0;

编写c++程序用函数重载方法求两个整数、两个浮点数、两个字符的最小者。

原文地址: https://www.cveoy.top/t/topic/fIMq 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录