梧桐下的四叶草 2015-06-06 03:36 采纳率: 33.3%
浏览 1397
已采纳

下面的Pascal代码能帮我翻译为c++吗??

const
wq:array[1..4,1..2] of longint=((-1,0),(0,1),(1,0),(0,-1));
var
i,j,ans,tot:longint;
map:array[0..10,0..10]of longint;
s:array[0..999999]of boolean;
procedure prin(x,y,dep:longint);
var
i,x1,y1:longint;
begin
if dep=6 then begin
if not s[tot] then begin
inc(ans);
s[tot]:=true;
end;
end else for i:=1 to 4 do begin
x1:=x+wq[i,1];
y1:=y+wq[i,2];
if (x1>0) and (x1<=5) and (y1>0) and (y1<=5) then begin
tot:=tot*10+map[x1,y1];
prin(x1,y1,dep+1);
tot:=tot div 10;
end;
end;
end;
begin
for i:=1 to 5 do begin
for j:=1 to 5 do read(map[i,j]);
readln;
end;
ans:=0;
tot:=0;
for i:=1 to 5 do begin
for j:=1 to 5 do begin
tot:=tot*10+map[i,j];
prin(i,j,1);
tot:=0;
end;
end;
writeln(ans);
end.

  • 写回答

3条回答 默认 最新

  • 普通网友 领域专家: 编程技术技术领域 2015-06-06 04:01
    关注

    想学 Pascal,就应该 看 Pascal 的代码
    别人给你翻译成C ,难道你是想学 C 不成?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?