Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $input=fgets(STDIN);
- $arrayInput=explode(" ",$input);
- $lenArr=count($arrayInput);
- $leftSum=0;
- $rightSum=0;
- for($i=0; $i < $lenArr; $i++) {
- for ($right = $i + 1; $right < $lenArr; $right++) {
- $rightSum += $arrayInput[$right];
- }
- // echo "{$rightSum}\n";
- for ($left = 0; $left <=$i-1; $left++) {
- if ($i == 0) {
- break;
- } else {
- $leftSum += $arrayInput[$left];
- }
- }
- // echo "{$leftSum}\n";
- if ($rightSum == $leftSum) {
- echo $i;
- return;
- }
- $leftSum=0;
- $rightSum=0;
- // else{
- // echo "no";
- // }
- }
- echo "no";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement