7 solutions
-
2
#include <iostream> #include <algorithm> #include <iomanip> using namespace std; int main() { double x, y = 0; cin >> x; if(x < 5 && x >= 0) y = 2.5 - x; else if(x < 10 && x >= 5) y = 2 - 1.5 * (x - 3) * (x - 3); else y = x / 2 - 1.5; cout << fixed << setprecision(3) << y << endl; return 0; }
-
1
#include<bits/stdc++.h> using namespace std; int main(){ double x; cin>>x; if(0<=x&&x<5){ cout<<fixed<<setprecision(3)<<-x+2.5;
} else if(5<=x&&x<10){ cout<<fixed<<setprecision(3)<<2-1.5*(x-3)*(x-3);} else if (10<=x&&x<20){ cout<<fixed<<setprecision(3)<<x/2-1.5;} return 0;
}
😄 看看我的最基础题解
-
1
#include <iostream> #include <algorithm> #include <iomanip> using namespace std; int main() { double x, y = 0; cin >> x; if(x < 5 && x >= 0) y = 2.5 - x; else if(x < 10 && x >= 5) y = 2 - 1.5 * (x - 3) * (x - 3); else y = x / 2 - 1.5; cout << fixed << setprecision(3) << y << endl; return 0; }
-
1
#include using namespace std; void f(float x); int main(int argc, char **argv){ float x; cin >> x; f(x); return 0; } void f(float x){ double y; if (x < 5){ y = -x + 2.5; printf("%.3f",y); }else if(x < 10){ y = 2 - 1.5 * (x - 3) * (x - 3); printf("%.3f",y); }else if(x < 20){ y = (x / 2) - 1.5; printf("%.3f",y); } }
- 1
Information
- ID
- 538
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- # Submissions
- 226
- Accepted
- 114
- Uploaded By