Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function check_points($x, $y, $r)
- {
- if(($x > 0 && $y>0 && $y< (-2*$x+$r)) ||
- ($x >0 && $x < $r/2 && $y < 0 && $y > -$r) ||
- ($x < 0 && $y > 0 && $x*$x+$y*$y < $r*$r))
- {
- return "hit";
- }
- else
- {
- return "missed";
- }
- }
- $R =$_GET['r'];
- if(isset($R))
- {
- foreach($R as $item)
- {
- $validate_r[$item]=preg_match('/^[0-9]+$/', $item) ? $item : 'incorrect value';
- }
- }
- $X=preg_match('/^-?[0-9]+$/', $_GET['cordinate-x']) ? $_GET['cordinate-x'] : 'incorrect value';
- $Y=preg_match('/^-?[0-9]+([,.]?[0-9]+)?$/', $_GET['cordinate-y']) ? $_GET['cordinate-y'] : 'incorrect value';
- echo '<html><table border="1px"><tr><td><b>X</b></td><td><b>Y</b></td><td><b>R</b></td>
- <td><b>Result</b></td><tr>';
- foreach($R as $item)
- {
- echo '<tr><td>'.$X.'</td><td>'.$Y.'</td><td>'.$validate_r[$item].'</td>';
- if('incorrect value' != $validate_r[$item] && 'incorrect value' != $X && 'incorrect value' != $Y)
- {
- echo '<td>'.check_points($X, $Y, $item).'</td>';
- }
- else
- {
- echo '<td>incorrect value</td>';
- }
- echo '</tr>';
- }
- echo '</table></html';
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement