解题思路:
注意事项:注意要用 double 或者float
用if 的多重选择分支法可以让程序运行更快
参考代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
double x,y;
cin>>x;
if(x<1)
y=x;
else{
if(x>=1&&x<10)
y=2*x-1;
else if(x>=10)
y=3*x-11;
}
cout << y <<endl;
return 0;
}
0.0分
2 人评分