Aer/tests/static_var.aer

26 lines
560 B
Plaintext
Raw Normal View History

2019-04-11 13:29:44 +02:00
class Program {
string cycle(char $a, char $b, int $i = 0) {
static char[] $switches;
if($switches[$i])
$switches[$i] = !$switches[$i];
else
!($switches[$i] = true);
return ($switches[$i]) ? $a : $b;
}
void main() {
int $i, $j, $k;
for($i = 1; $i < 3; $i++) {
2019-04-11 13:29:44 +02:00
print($i + $this->cycle('a', 'b') + PHP_EOL);
for($j = 1; $j < 5; $j++) {
2019-04-11 13:29:44 +02:00
print(' ' + $j + $this->cycle('a', 'b', 1) + PHP_EOL);
for($k = 1; $k < 3; $k++) {
2019-04-11 13:29:44 +02:00
print(' ' + $k + $this->cycle('c', 'd', 2) + PHP_EOL);
}
}
}
}
}