-
Notifications
You must be signed in to change notification settings - Fork 0
/
kings.php
38 lines (35 loc) · 1.13 KB
/
kings.php
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
<?php
/*************************************************************************
* The Problem Solved Kings in PHP *
* ---------------------------------------------------------------------- *
* *
* POC: $ php kings.php <number of rows> <number of columns> *
* *
* Autor: Elton Fonseca *
* http://www.fb.com/elton.junior6 *
**************************************************************************/
function main($argv, $argc)
{
if($argv == null || $argc < 3 || $argc > 3)
print("Error!\n");
else
kings($argv[1], $argv[2]);
}
function kings($rows, $columns)
{
$king = 0;
$i = 1;
while($i <= $rows)
{
$j = 1;
while($j <= $columns)
{
$king++;
$j += 2;
}
$i += 2;
}
print("Kings: " . $king . "\n");
}
main($argv, $argc);
?>