1.问题及代码
/*
文件名称:Exl - 1.cpp
作 者:罗天佑
完成日期:2017年3月13日
版 本 号:v1.0
对任务及求解方法的描述部分
输入描述:输入未知数X
问题描述:多分数段函数求值
程序输出:根据下面的公式计算并输出y的值
问题分析:输入的x为实型
算法设计:运用了 if else 语句
*/
#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<<endl;
return 0;
}
2.运行结果
3.心得体会
对于if else 语句的使用还要加强
4.知识点总结
运用了if else 语句来实现函数分段