|
|
back to boardWhy WA2? I think I my prog is correct... Who can help me? My prog gives WA#2... Do I have any bug in my prog? Here's my code: var k,i,j,nc,n:integer; mas,ar:array [1..100] of integer; function bool(x:integer):boolean; var l:integer; begin l:=0; bool:=false; for l:=1 to j do if mas[l]=x then begin bool:=true; break; end; end; begin readln(n,k); for i:=1 to n do read(ar[i]); if n mod 2=0 then nc:=round(n/k) else nc:=round(n/k+1); i:=1; j:=0; while true do begin if (not bool(i))and(i<=n) then begin inc(j); mas[j]:=i; write(ar[i]:4); if j>=n then exit; inc(i,nc); end else if i>n then begin writeln; i:=1; end else if bool(i) then inc(i); end; end. Edited by author 26.10.2007 02:33 Re: Why WA2? I think I my prog is correct... Who can help me? Input: 5 3 1 2 30 40 50 600 700 Output(Your): 1 40 2 50 30 Output(Right): 1 30 50 2 40 GL! Re: Why WA2? I think I my prog is correct... Who can help me? Yes, thanks i understood my mistake. Sorry but i don't have any idea according to correcting it? Can you help me,please? |
|
|