#35667: answer


1452945-9@g.puiching.edu.mo (sandy koya)

學校 : 不指定學校
編號 : 188268
來源 : [27.109.238.197]
最後登入時間 :
2023-07-23 11:53:37
k392. 分段函數 | From: [27.109.237.203] | 發表日期 : 2023-06-11 15:45

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
using namespace std;
int main(){
    double x;
    while (cin >> x){
        if (x <= -10){
            double result = abs(pow(x,5)) - 33;
            printf("%.1lf",result);
        }else if (x <= 10){
            double result = -0.5 * x + 10;
            printf("%.1lf",result);
        }else{
            double result = 2 * sqrt(x);
            printf("%.1lf",result);
        }
    }
}
 
ZeroJudge Forum