Absolute Difference
PHP
Easy
5 views
Problem Description
Given a and b, print |a-b|.
Input Format
One line: a b.
Output Format
One integer.
Official Solution
<?php
$inputText=trim(stream_get_contents(STDIN));
if($inputText==='') exit;
[$a,$b]=array_map('intval',preg_split('/\\s+/', $inputText));
$diff=$a-$b;
if($diff<0) $diff=-$diff;
echo $diff;
?>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!