#include<iostream> //预操作
#include<cmath>
using namespace std;// 使用命名空间std
double sroot(int a)
{
return (sqrt(a));
}
double sroot(long b)
{
return (sqrt(b));
}
double sroot(double c)
{
return sqrt(c);
}
int main()
{
int a = 5;
long b = 1234;
double c = 10.99;
cout << "a的平方根为:" << sroot(a) << endl;
cout << "b平方根为:" << sroot(b) << endl;
cout << "c的平方根为:" << sroot(c) << endl;
system("pause");
return 0;
}
C++:建立一个被称为sroot()的函数,返回其参数的二次方根。重载sroot()3次,让它返回整数、长整数与双精度的二次方根
最新推荐文章于 2024-05-24 20:40:37 发布