有一个函数:
y = x (x<1)
2x-1 (1<=x<10)
3x-11 (x>=10)
编写一个程序,输入x,输出y的值。
#include "stdafx.h"
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
double x,y;
cin>>x;
if(x<1)
{
y = x;
}
else if(x>=1&&x<10)
{
y = 2*x-1;
}
else
{
y = 3*x-11;
}
cout<<"y="<<y<<endl;
return 0;
}