-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyphp.php
More file actions
128 lines (114 loc) · 3.44 KB
/
myphp.php
File metadata and controls
128 lines (114 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
$begin = microtime(true);
if (isset($_POST['X']))
$X = $_POST['X'];
else
$X = "(He введено)";
if (isset($_POST['Y']))
$Y = $_POST['Y'];
else
$Y = "(He введено)";
if (isset($_POST['R']))
$R = $_POST['R'];
else
$R = "(He введено)";
if (! (isset($X) && isset($Y) && isset($R))) {
echo "<td>Как минимум одна из переменных не введена.</td>";
exit();
}
if (! (is_numeric($X) && is_numeric($Y) && is_numeric($R))) {
echo "<td>Как минимум одна из переменных не является числом.</td>";
exit();
}
if (checkRound($X, $Y, $R) || checkTriangle($X, $Y, $R) || checkSquare($X, $Y, $R))
$answer = "Принадлежит";
else
$answer = "Не принадлежит";
$duration = 1000*round((microtime(true) - $begin),5);
function checkRound($arg1, $arg2, $arg3)
{
if (($arg1 * $arg1 + $arg2 * $arg2 <= $arg3 * $arg3) && ($arg1 >= 0) && ($arg2 >= 0))
$rez = true;
else
$rez = false;
return $rez;
}
function checkTriangle($arg1, $arg2, $arg3)
{
if ($arg1 <= 0 && $arg2 >= 0) {
$x0 = $arg1;
$y0 = $arg2;
$x1 = - 1 * $arg3;
$y1 = 0;
$x2 = 0;
$y2 = $arg3 / 2;
$x3 = 0;
$y3 = 0;
$r1 = ($x1 - $x0) * ($y2 - $y1) - ($x2 - $x1) * ($y1 - $y0);
$r2 = ($x2 - $x0) * ($y3 - $y2) - ($x3 - $x2) * ($y2 - $y0);
$r3 = ($x3 - $x0) * ($y1 - $y3) - ($x1 - $x3) * ($y3 - $y0);
if (($r1 > 0 && $r2 > 0 && $r3 > 0) || ($r1 < 0 && $r2 < 0 && $r3 < 0) || $r1 = 0 || $r2 = 0 || $r3 = 0)
return true;
else
return false;
} else
return false;
}
function checkSquare($arg1, $arg2, $arg3)
{
if (($arg1 <= $arg3) && (abs($arg2) <= $arg3) && ($arg1 >= 0) && ($arg2 <= 0))
return true;
else
return false;
}
?>
<html>
<head>
<title>Results</title>
<script type="text/javascript">
function digitalWatch() {
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
if (hours < 10) hours = "0" + hours;
if (minutes < 10) minutes = "0" + minutes;
if (seconds < 10) seconds = "0" + seconds;
document.getElementById("digital_watch").innerHTML = hours + ":" + minutes + ":" + seconds;
setTimeout("digitalWatch()", 1000);
}
</script>
<style>
@import url( 'mystyle.css');
</style>
</head>
<body onload="digitalWatch()">
<div class="tbl-header" id="resulthead">
<table border="0" width="100%">
<thead>
<tr>
<th><p>X:</p></th>
<th><p>Y:</p></th>
<th><p>R:</p></th>
<th><p>Results</p></th>
<th><p>Completion time</p></th>
</tr>
</thead>
</table>
</div>
<div class="tbl-content" id="resultbody">
<table border="0" >
<tbody>
<tr>
<td><p style= "text-align:center; word-wrap: break-word;"><?php echo $X; ?></p></td>
<td><p style= "text-align:center; word-wrap: break-word;"><?php echo $Y; ?></p></td>
<td><p style= "text-align:center; word-wrap: break-word;"><?php echo $R; ?></p></td>
<td><p style= "text-align:center; word-wrap: break-word;"><?php echo $answer; ?></p></td>
<td><p style= "text-align:center; word-wrap: break-word;"><?php echo $duration; ?></p></td>
</tr>
</tbody>
</table>
</div>
<p id="digital_watch" style="color: #FCA5D3; font-size: 120%; font-weight: bold; text-align: center;"></p>
</body>
</html>