68求调

B2047 分段函数

gaizhanghaoyizhuxiao @ 2025-01-11 12:48:50

#include<bits/stdc++.h>
using namespace std;
int main(){
    double n;
    cin>>n;
    if(n>=0&&n<=5){
        cout<<fixed<<setprecision(3)<<(-n)+2.5;
    } 
    if(n>=5&&n<=10){
        cout<<fixed<<setprecision(3)<<2-1.5*(n-3)*(n-3);
    } 
    if(n>=10&&n<=20){
        cout<<fixed<<setprecision(3)<<n/2-1.5;
    } 
} 

|