求C 翻譯成pascal,求C 翻譯成pascal

時間 2022-05-28 23:30:03

1樓:匿名使用者

maxn是多少,常量沒定義呀??

況且沒有主程式。

*r,*sa,*san等等沒有找到定義呀??

求c++翻譯pascal

2樓:

大體修改如下,沒除錯

const

n=500000+5;

type

myrec=record

l,r,cnt:integer;

end;

vara:array [0..n*4-1] of myrec;

bo:array [0..n-1] of boolean;

n,m,x,i:integer;

op:string;

procedure build(l,r,k:integer);

var mid:integer;

begin

a[k].cnt:=r-l+1; a[k].l:=l; a[k].r:=r;

if (l=r) exit;

mid:=(l+r) div 2;

build(l,mid,k*2);

build(mid+1,r,k*2+1);

end;

procedure del(x,k:integer);

begin

a[k].cnt:=a[k].cnt-1;

if a[k].l=a[k].r thenbegin

bo[a[k].l]:=false;

exit;

end;

if x<=a[k*2].cnt then del(x,k*2)else del(x-a[k*2].cnt,k*2+1);

end;

procedure ins(x,k:integer);

var mid:integer;

begin

inc(a[k].cnt);

if a[k].l=a[k].r then exit;

mid:=(a[k].l+a[k].r)/2;

if x<=mid then ins(x,k*2)else ins(x,k*2+1);

end;

function query(x,k:integer):integer;

begin

if a[k].l=a[k].r thenbegin

query:=a[k].l;

exit;

end;

if x<=a[k*2].cnt thenquery:=query(x,k*2);

else

query:=query(x-a[k*2].cnt,k*2+1);

end;

begin

readln(n,m);

build(1,n,1);

for i:=1 to n-1 do

begin

bo[i]:=true;

end;

for i:=1 to m do

begin

readlen(op,x);

if op[1]='l' then

del(x,1)

else

if op[1]='r') then

begin

if (bo[x]=false) thenbegin

bo[x]:=true;

ins(x,1);

end;

endelse if op[1]='q' thenwriteln(query(x,1);

end;

end.

求高手將c++翻譯成pascal。。高跟懸賞,,謝了~

3樓:匿名使用者

有年頭不寫pascal了,手生了,雖然編譯通過了,結果不太敢保證對,將就著看吧。

const maxn=50;

varn,v1:longint;

s:array[0..maxn-1]of string;

v:array[0..maxn-1,0..maxn-1]of longint;

visine:array[0..maxn*maxn-1]of longint;

bio:array[0..maxn-1,0..maxn-1]of longint;

i,j,tmp,ret,x1,lo,hi,x2:longint;

procedure dfs(x,y:longint;v1,v2:longint);

var dx,dy,nx,ny:longint;

begin

if (bio[x,y]>0) then exit;

bio[x,y]:=1;

for dx:=-1 to 1 do

for dy:=-1 to 1 do if (dx or dy>0) then

begin

nx:=x+dx;

ny:=y+dy;

if ((nx<0)or(nx>=n)) then continue;

if ((ny<0)or(ny>=n)) then continue;

if ((v[nx,ny]v2)) then continue;

dfs(nx,ny,v1,v2);

end;

end;

function f(v1,v2:longint):boolean;

var i,j:longint;

begin

fillchar(bio,sizeof(bio),0);

for i:=0 to n-1 do

for j:=0 to n-1 do if (s[i,j]='p') then

begin

if ((v[i,j]v2)) then begin f:=false;exit;end;

dfs(i,j,v1,v2);

end;

for i:=0 to n-1 do

for j:=0 to n-1 do

if ((s[i,j]='k')and(bio[i,j]=0)) then begin f:=false;exit;end;

f:=true;

end;

begin

read(n);

for i:=0 to n-1 do read(s[i]);

v1:=0;

for i:=0 to n-1 do

for j:=0 to n-1 do

begin

read(v[i,j]);

visine[v1]:=v[i,j];

inc(v1);

end;

for i:=0 to v1-2 do

for j:=1 to v1-1 do

if (visine[i]>visine[j]) then

begin tmp:=visine[i];visine[i]:=visine[j];visine[j]:=tmp;end;

for i:=v1-1 downto 1 do

if (visine[i]=visine[i-1]) then

begin

for j:=i to v1-2 do visine[j]:=visine[j+1];

dec(v1);

end;

ret:=1<<30;

for x1:=0 to v1-1 do

begin

lo:=x1;

hi:=v1-1;

while (lovisine[lo]-visine[x1]) then ret:=visine[lo]-visine[x1];

end;

writeln(ret);

end.

另外寫pascal的習慣array[1..maxn]以及for i:=1 to n do 而不是用array[0..

maxn-1]和for i:=0 to n-1 do,可以自己改改。

求高手將下列pascal**翻譯成c++ 15

4樓:

#include

#inlucde

#include

void randomize()

int random(int n)

int main()

}//end;

}//end;

}//end.

求翻譯成中文,求翻譯成中文

最後,在2007年至2008年中期的消費者對食品 上升的驅動因素分解的歷史表明,商品 衝擊解釋了大部分的明顯上升,但生產者和消費者 的反應似乎 有些之上歷史的常態。雖然這樣的 增加部分抵消了以前的 生產商和零售商的利潤率惡化,它們的大小表明,可能已經被提出,多餘的將被指揮的 僅僅是直通的投入成本上升...

求翻譯成英文,求翻譯成英文

翻譯如下 a popular chinese confucian culture disseminated folk financial leader,from the business sea wrestle with keen insight grasp the folk capital mar...

求翻譯中文,求翻譯成中文

吳亦凡 robin,博物館在哪兒?我想買一個明信片。robin 在門附近。吳亦凡 謝謝。郵局在哪兒?我想今天就發出去。robin 我不知道。我會問。打擾一下,先生。先生 哇哦 會說話的機器人 多麼棒的博物館 robin 郵局在哪兒?先生 在博物館旁邊。robin 謝謝。 玲瓏藝雪 robin,博物館...