Files
some-cpp-files/Miscellaneous/func_2.cpp
T
2024-03-17 22:30:49 +08:00

29 lines
259 B
C++

#include <bits/stdc++.h>
using namespace std;
int main() {
printf("x=");
double x, y;
int type;
scanf("%lf", &x);
type = x < 0;
switch (type) {
case 1:
y = -1;
break;
case 0:
y = 2 * x;
break;
}
printf("f(x)=%f\n", y);
return 0;
}