您的位置:首页 > 其它

第九周上级任务之分段函数求解

2012-10-22 19:04 239 查看
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
float x,y;
cin>>x;
if(x<0)
cout<<"Input error!"<<endl;
else

if(0<=x&&x<2)
y=x;
else
if(2<=x&&x<6)
y=x*x+1;
else
if(6<=x&&x<10)
y=sqrt(x+1);
else
y=1/(x+1);
cout<<"x="<<x<<",y="<<y<<endl;

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: