hzy0928 @ 2024-11-30 11:36:01
#include<bits/stdc++.h>
using namespace std;
int main(){
double x;
cin >> x;
if(x >= 0 && x < 5){
printf("%.3f" , -x + 2.5);
}else if(x >= 5 && x < 10){
printf("%.3f" , 2 - 1.5 * (x - 3) * (x * 3));
}else{
printf("%.3f" , x / 2 - 1.5);
}
return 0;
}
by 3_14 @ 2024-11-30 11:43:01
#include<bits/stdc++.h>
using namespace std;
double x, y;
int main(){
cin>>x;
if(x<5){
y=-x+2.5;
}else if(x<10){
y=2-1.5*(x-3)*(x-3);
}else{
y=x/2-1.5;
}
printf("%.3lf\n",y);
return 0;
}
by 3_14 @ 2024-11-30 11:43:40
求关
by TAOTAO2011 @ 2024-11-30 11:43:58
@hzy0928你这个第二个if错了吧
by TAOTAO2011 @ 2024-11-30 11:44:36
@hzy0928不是x*3是x-3
by 3_14 @ 2024-11-30 11:59:38
同楼上
by hzy0928 @ 2024-11-30 21:03:36
@TAOTAO2011 谢谢