*Copyright (c) 2014, 烟台大学计算机学院
*All rights reserved.
*文件名称:text.cpp<
*作者:曹莉萍
*完成日期:2014.10.21
*版本号:v1.0
*问题描述:计算函数的值。
*输入描述:一个整数x
*程序输出:对应的y 值
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x,y;
cout<<"输入一个数:";
cin >>x;
if (x<2)
{
y=x;
cout <<"y="<<y<<endl;
}
if (x>=2&&x<6)
{
y=x*x;
cout <<"y="<<y<<endl ;
}
if (x>=6 &&x<10)
{
y=sqrt(x+1);
cout <<"y="<<y<<endl;
}
if (x>=10)
{
y=1/(x+1);
cout<<"y="<<y<<endl;
}
return 0;
}
<知识点总结:有数学表达的,记得加上cmath。
学习心得:自己做的程序,再接再厉啊,加油!