帕斯卡函数的一部分
我正在尝试将pascal程序重写为PHP,但不明白这部分pascal函数的作用:
while (u[3] <> 1) and (u[3]<>0) and (v[3]<>0)do
begin
q:=u[3] div v[3];
for i:=1 to 3 do
begin
t:=u[i]-v[i]*q;
u[i]:=v[i];
v[i]:=t;
{writeln('u',i,'=',u[i],' v',i,'=',v[i]); }
end;
end;
if u[1]<0 then u[1]:=n+u[1];
rae:=u[1];
请帮助将其重写为PHP。
谢谢。
I'm trying to rewrite a pascal program to PHP, and don't understand what this part of pascal function do:
while (u[3] <> 1) and (u[3]<>0) and (v[3]<>0)do
begin
q:=u[3] div v[3];
for i:=1 to 3 do
begin
t:=u[i]-v[i]*q;
u[i]:=v[i];
v[i]:=t;
{writeln('u',i,'=',u[i],' v',i,'=',v[i]); }
end;
end;
if u[1]<0 then u[1]:=n+u[1];
rae:=u[1];
Please help to rewrite it to PHP.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
该代码的非常字面翻译应该是这样的:
当然,u 和 v 是数组。很抱歉没有提供更多信息,但我和 Pascal 上次见面已经有 10 年了,但我们已经有很长一段时间的深厚浪漫了,因为我爱上了辣妹(C# 和 PHP):)
A very literal translation of that code, should be this one:
Of course, u and v are arrays. Sorry for not giving any more info, but it's been like 10 years since Pascal and I last saw each other, but we had a profound romance for a long time, since I feel inlove for to hotties(C# and PHP) :)
对 David 代码的 2 个小修正:
应该是,
并且
i 永远不会达到 3 的值
可能 Writeln 可以翻译为
当您进行数组翻译时,请考虑到 php 中的数组使用 0 作为第一个索引。
2 small corrections to David's code:
should be
and
i never reaches the value of 3
May be the Writeln can be translated to
When you do the translation of arrays, take into account that arrays in php uses 0 as the first index.
我不知道 pascal 但我已经尝试过:)
I dont know pascal But i have tried :)