/*
Copyright (c) 烟台大学计算机与控制工程学院
Author:刘慧艳
Created:2014.07.16
Edition:V1.0
Describe:分段函数求值
*/
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x,y;
cin>>x;
if(x<0)
cout<<"Input error!"<<endl;
else
{
if(x<2)
y=x;
else if(x<6)
y=x*x+1;
else if(x<10)
y=sqrt(x+1);
else
y=1/(x+1);
cout<<"x="<<x<<",y="<<y<<endl;
}
return 0;
}
分段函数求值2.1
最新推荐文章于 2023-09-30 18:32:28 发布