Guest User

Untitled

a guest
Oct 3rd, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. $n = intval(readline());
  3. $sumLeft = 0.0;
  4. $sumRight = 0.0;
  5.  for($i = 1; $i <= $n; $i++) {
  6.      $nums = explode(" ", readline());
  7.      if(is_numeric($nums[0]) && is_numeric($nums[1])) {
  8.       if($nums[0] > $nums[1]) {
  9.           for($j = 0; $j < strlen($nums[0]); $j++) {
  10.               $sumLeft += $nums[0][$j];
  11.           }
  12.       } else if($nums[1] >= $nums[0]) {
  13.           for($k = 0; $k < strlen($nums[1]); $k++) {
  14.               $sumRight += $nums[1][$k];
  15.           }
  16.       }
  17.       echo $sumLeft + $sumRight . PHP_EOL;
  18.       $sumLeft = 0.0;
  19.       $sumRight = 0.0;
  20.      }
  21.  }
  22.  
  23. ?>
Add Comment
Please, Sign In to add comment