求把这段代码翻译成c++代码
顺便弱弱的问一句,还有没有别的思路啊var m,n,j,k,i,x1,x2,y1,y2,x,max1,max2,t,max,ans:longint;
a:array[1..1000,1..1000]of longint;
procedure maxx(var x,y,max:longint);
begin
max:=0;
for i:=1 to m do
for j:=1 to n do
if (a[i,j]>max) then begin max:=a[i,j];x:=i;y:=j;end;
end;
begin
read(m,n,t);
for i:=1 to m do
for j:=1 to n do read(a[i,j]);
maxx(x2,y2,max);
x:=0;y1:=y2;
while t>abs(x1-x2)+abs(y1-y2)+x2+1 do
begin
t:=t-(abs(x1-x2)+abs(y1-y2)+1);
a[x2,y2]:=0;
x1:=x2;y1:=y2;
inc(ans,max);
maxx(x2,y2,max);
end;
writeln(ans);
end.