E
E
Egor Traurov2014-12-26 23:08:50
PHP
Egor Traurov, 2014-12-26 23:08:50

How would the code from Pascal to PHP look like?

Hello.
I studied Pascal for a long time, I forgot everything. And here it is necessary to translate the code from Pascal into PHP. Help, good people :)

for i:=1 to n div 2 do
for j:=1 to n do
 begin
  x:=a[i,j];
  a[i,j]:=a[n-i+1,j];
  a[n-i+1,j]:=x;
 end;

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Stanislav Pochepko, 2014-12-26
@ProMaks

for ($i = 1; $i <= $n%2; $i++) {
for ($j = 1; $j <= $n%2; $i++) {
$x = a[$i][$ j];
$a[$i][$j] = $a[$n-$i+1][$j];
$a[$n-$i][$j] = $x;
}
}

F
Flaker, 2014-12-26
@Flaker

Well, look:
1) Install git
1.1) Optionally install PowerShell
2) Install node
3) Install bower
4) Install gulp
5) Install Composer
6) Install Laravel via Composer
7) Install JeffreyWay/Laravel-4-Generators
8) Install REST via a generator
9) Install Angular
10) Install Browserify
11) Install Bootstrap
12) Make an array input form in our SPA using angular two-way binding, and Bootstrap design (We will custom sculpt later, at the first stage, the main prototype in a short time)
13) We do validation on the client
14) We do the reception and validation of data on the server (Do not forget, we are sitting on REST, so we comply)
15) We write your code from Pascal to convert array, using the full power of PHP:
16) Rendering it all in JSON, of course:
17) Displaying the data on the client

S
Sergey, 2014-12-26
@gangstarcj

php.net/manual/en/control-structures.for.php

S
SagePtr, 2014-12-27
@SagePtr

This is how it looks like:
sort($a);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question