问题及代码:
/*
*Copyright(c)2014,烟台大学计算机学院
*Allrights reserved.
*文件名称:MADE3.cpp
*作 者:张生栋
*完成日期:2014年10月17日
*版 本 号:v1.0
*
*/
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int 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/(x+1);
cout << "函数的值为:" <<y<< endl;
return 0;
}
运行结果: