用递归做的,测试样例过了,只有4和6是对的,请求支援
查看原帖
用递归做的,测试样例过了,只有4和6是对的,请求支援
1040753
KARA_214楼主2023/8/7 15:47
#include <bits/stdc++.h>
using namespace std;
double f(double x){
	if(0<=x<5) return 0-x+2.5;
	if(5<=x<10) return 2-1.5*(x-3)*(x-3);
	if(10<=x<20) return x/2-1.5;
}
int main(){
	double y;
	cin>>y;
	cout<<fixed<<setprecision(3)<<f(y)<<endl;
	return 0;
}

2023/8/7 15:47
加载中...