c++程序设计第3版谭浩强课后答案
有一个函数如下:
{ x ( x<1 )
y={ 2x-1 ( 1<=x<10 )
{ 3x-11 ( x>=10 )
写一程序,输入x 输出y值
以下是此题的【c++源代码】,需要C源代码的请点击
#include <iostream>
using namespace std;
int main ( )
{int x,y;
cout<<"enter x:";
cin>>x;
if (x<1)
{y=x;
cout<<"x="<<x<<", y=x="<<y;
}
else if (x<10) // 1≤x<10
{y=2*x-1;
cout<<"x="<<x<<", y=2*x-1="<<y;
}
else // x≥10
{y=3*x-11;
cout<<"x="<<x<<", y=3*x-11="<<y;
}
cout<<endl;
return 0;
}
本文链接:http://www.wb98.com/cjia/post/cjia_3.10.html
本站文章搜索: