68分求助
查看原帖
68分求助
662037
_Jonny_404楼主2022/8/23 13:11
#include<bits/stdc++.h>
using namespace std;

double x;
double f(int x){
	if(x>=0.0&&x<5.0) return (0.0-x)+2.5;
	else if(x>=5.0&&x<10.0) return 2.0-1.5*(x-3)*(x-3);
	else if(x>=10.0&&x<20.0) return x/2.0-1.5;
}

int main(){
	scanf("%lf",&x);
	printf("%.3lf",f(x));
	return 0;
}
2022/8/23 13:11
加载中...