|
|
back to boardAnd where is my mistake? program stone; const nmax=20; var i,k,n:byte; x:longint; a:array[1..nmax] of longint; begin read(n); For i:=1 to n do read(a[i]); For i:=2 to n do For k:=n downto i do If a[k-1]>a[k] then begin x:=a[k]; a[k]:=a[k-1]; a[k-1]:=x; end; while n>1 do begin a[n-1]:=a[n]-a[n-1]; dec(n); For i:=2 to n do For k:=n downto i do If a[k-1]>a[k] then begin x:=a[k]; a[k]:=a[k-1]; a[k-1]:=x; end; end; write(a[1]); read; end. May be I am too self-confident, but I am sure my program must work. But the fifth test refutes my confidence. If you are able to help, please,try to find mistake and write where it is=) Re: And where is my mistake? Your algo is incorrect. Test: 5 3 3 3 4 5 Answer: 0 Re: And where is my mistake? Thank you, I understood, I will at a new algo. |
|
|