/*
*Copyright (c) 2014,烟台大学计算机学院
*All rights reserved.
*文件名称:first.cpp
*作者:刘天恩
*完成时间:2014年10月16号
*版本号:v1.0
*问描述:输入x,计算并输出y的值
*输入描述:输入x
*程序输出:输出y
*/
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x,y;
cin>>x;
if(x<2)
y=x;
else if(x>=2&&x<6)
y=x*x+1;
else if(x>=6&&x<10)
y=sqrt(x+1);
else
y=1.0/(x+1);
cout<<"y="<<y<<endl;
return 0;
}
运行结果: