编写一个程序,实现根据上输入的x值,可求出y的值,并输出x和y的值。计算y值的数学公式为:y=1.5x+7.5(x≤2.5)y=9.32x-34.2(x>2.5)
第1个回答 2012-03-19
很简单的
#include <iostream>
using namespace std;
void main()
{
double x,y;
cin>>x;
if(x<=2.5)
y=1.5*x+7.5
else
y=9.32*x-34.2;
cout<<"x="<<x<<" "<<“y=”<<y<<endl;
}本回答被提问者采纳
#include <iostream>
using namespace std;
void main()
{
double x,y;
cin>>x;
if(x<=2.5)
y=1.5*x+7.5
else
y=9.32*x-34.2;
cout<<"x="<<x<<" "<<“y=”<<y<<endl;
}本回答被提问者采纳