c++
#include <iostream>
using namespace std;
int n, x;
double y;
int main()
{
cin >> n;
while (cin >> x)
{
if (x >= 0 && x < 2) y = -x + 2.5;
else if (x >= 2 && x < 4) y = 2 - 1.5 * (x - 3) * (x - 3);
else y = (double)x / 2 - 1.5;
printf("y=%.1f\n", y);
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发