16分蒟蒻,帮帮

B2047 分段函数

Mizuki0322 @ 2023-12-30 23:57:58

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define int long long
double n,ans;
inline double f(double x){
    int y;
    if (x>=0 && x<5){
        y=-x+2.5;
    }else if (x>=5 && x<10){
        y=2-1.5*(x-3)*(x-3);
    }else{
        y=x/2-1.5;
    }
    return y;
}
signed main(){
    #ifndef ONLINE_JUDGE
        freopen("nightingale.in","r",stdin);
        freopen("nightingale.out","w",stdout);
    #endif
    scanf("%lf",&n);
    ans=f(n);
    printf("%.3lf",ans);
    return 0;
}

by H2ptimize @ 2023-12-31 00:04:17

int y 是认真的?


by H2ptimize @ 2023-12-31 00:04:28

@Mizuki0322


|