发布网友 发布时间:2024-10-23 19:29
共2个回答
热心网友 时间:2024-11-07 18:51
#include <iostream>
using namespace std;
class Abs{
double x;
public:
Abs(double a):x(1) {
x = a;
cout<<x<<"的绝对值是:"<<(x>=0?x:-1.0*x)<<endl;
}
};
int main(){
double s = 1.0;
cin>>s;
Abs num(s);
return 0;
}
热心网友 时间:2024-11-07 18:46
#include <iostream>
using namespace std;
template<class T> inline T abs(T x){return x>0?x:-x;}
int main()
{
return 0;
}