求多个选择情况下的函数值

来源:互联网 发布:雷云mac版安装失败 编辑:程序博客网 时间:2024/05/01 04:32
#include<iostream>
using namespace std;
int main()


{
int x,y;
cout<<"请输入int型x值:"<<"\n";
cout<<"x=";
cin >>x;
cout<<"那么:"<<endl;
if(x>=10)
{ y=-(x+7)*(x-7);
cout<<"该函数执行的是y=-(x-7)*(x+7)"<<endl;}
else if(x>=6)
{ y=(x+1)*(x+1);
cout<<"该函数执行的是y=(x+1)*(x+1)"<<endl;}
else if (x>=2)
{y=x*x+1;
cout<<"该函数执行的是y=x*x+1"<<endl;
}
else
{y=x-55;
cout<<"该函数执行的是y=x-55"<<endl;}
cout<<"\\你所求的y的值是:\\"<<"\"y="<<y<<"\""<<"\n";
return 0;


}
0 0
原创粉丝点击