GAOXINGYI0703 @ 2024-10-07 16:44:49
#include <bits/stdc++.h>
using namespace std;
double x,y;
int main() {
cin>>x;
if(x>=0&&x<5) {
y=(-1*x)+2.5;
printf("%.3f",&y);
}
if(x>=5&&x<10) {
y=(2-1.5)*(x-3)*(x-3);
printf("%.3f",&y);
}
if(x>=10&&x<20) {
y=(x/2)-1.5;
printf("%.3f",&y);
}
return 0;
}
by lichitao75 @ 2024-10-07 16:49:24
#include<bits/stdc++.h>
using namespace std;
float x;
int f() {
double y;
if(x>=0&&x<5) {
x=-x;
y=x+2.5;
cout<<fixed<<setprecision(3)<<y;
return 0;
}
if(x>=5&&x<10) {
y=2-1.5*(x-3)*(x-3);
cout<<fixed<<setprecision(3)<<y;
return 0;
}
if(x>=10&&x<20) {
y=x/2-1.5;
cout<<fixed<<setprecision(3)<<y;
return 0;
}
}
int main() {
cin>>x;
f();
return 0;
}
咳咳咳,知道该给些什么吧
by GAOXINGYI0703 @ 2024-10-07 16:51:39
感谢大佬,请收下卑微的关注和膝盖@lichitao75
by GAOXINGYI0703 @ 2024-10-07 16:59:48
有没有哪位大佬能在原代码上更改,一定献上卑微的关注和膝盖!!!