第8周项目2-求简分数函数值

来源:互联网 发布:dnf进去就网络中断 编辑:程序博客网 时间:2024/06/06 02:47
/**Copyright(C)2013,烟台大学计算机学院*All rights reserved.*文件名称:test.cpp*作者:李东奇*完成日期:2013年10月15日*版本号:v1.0**输入描述:1  2  8  19*问题描述:计算计算机函数值*程序输出:1  5  3   0.05*/#include <iostream>#include <Cmath>using namespace std;int main(){    double x,y;    cout<<"任意输入一个数:";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{if(x>=10){y=1/(x+1);}}}}cout<<"函数值为:"<<y<<endl;    return 0;}