问题及代码
*ALL rights reserved.
*文件名称:qiu y zhi
*作者:李长鸿
*完成时间:2014.10.16
*问题描述:求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<6)
y=x*x-1;
else if(x<10)
y=sqrt(x+1);
else
y=1/(x+1);
cout <<"y="<<y<<endl;
return 0;
}
<img src="https://img-blog.youkuaiyun.com/20141016151804572?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQveHNsY2gxMjM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
总结:不同的问题对应有不同的程序类型,觉得需要看书多了解