Absolute Without abs
Python
Easy
5 views
Problem Description
Read one integer n. Output its absolute value without using abs().
Input Format
One integer n.
Output Format
One integer absolute value.
Official Solution
import sys
s=sys.stdin.read().strip()
if not s: sys.exit(0)
n=int(s)
if n<0:
n=-n
sys.stdout.write(str(n))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!