My Absolute Value
0.5s 256MImplement a function named my_abs. The grader gives you an integer x, and you need to return the absolute value of x.
You need to implement the following function:
int my_abs(int x);
- The official grader will prepare the parameters
xand callmy_abs(x);. - Do not handle input or output by yourself.
- The judge will inspect your source code. Calling standard helpers such as
absthat directly solve the core task is forbidden. Implement the logic yourself insidemy_abs.
Input
The sample grader uses the following input format:
T
one line of parameters for each function call
Here, \(T\) is the number of times the sample grader calls my_abs.
Note that in the official judging, you do not read input yourself; the grader directly calls the function you implement.
Constraints
- \(1 \le T \le 50\)
- Every integer parameter is between \(-10^9\) and \(10^9\)
Output
The sample grader prints the result of each call. A bool result is printed as 1 for true and 0 for false.
Note that in the official judging, you do not print output yourself.
Sample Input 1
3
5
-7
0
Sample Output 1
5
7
0
Sample Input 2
4
-1000000000
1000000000
-1
1
Sample Output 2
1000000000
1000000000
1
1
Log in to write and submit code. Creating an account is free.