My task is "Integral Determinant". My number is 684.
I send my program but I have " complier error" . Why??? I have done all as said at "How to submit Pascal programs"… and have a compile error. I know that my program is work … may be not effectively… but it's work … and I confirm it's correctly counting determinants of all matrixes…
So if my program will not accepted I will have been banished from University .. if it will have been happened I will have only one way … way to Russian Army… way to Hell where I have finished my days..
May be I wrong and it's not correctly counting determinants … so show me the way how to make it correctly …. If you know how to dispose from this stupid error .. so show me how I can do it… if you won't people see your comments or program's code… send me to mail pushoc@freemail.ru
I put down my program below..
You know that in the web we exist without skin color, without nationality, without religious bias.. why you should not help me if you can ??? I'm just one alone person living in 9 billion's world. Is there somebody who help me and don't turn his back .. Believe me my life in your hands…
Sincerely Den.
program PXXX(input, output); { ISO states this line in this way }
{$IFNDEF ONLINE_JUDGE}
{$M 65500, 0 , 400000}
{$ENDIF}
const size=30; {The size of the matrix}
type Matrix=array[1..size,1..size] of integer;
var n:integer;
A:Matrix;
{//////////////////////////////////////////////////////
Input a matrix
//////////////////////////////////////////////////////}
function cut_number(search:string;var k:integer):integer;
var j,abba,Code:integer;
str:string;
begin
j:=1;
while search[k]=' ' do k:=k+1;
while (search[k]<>' ')and(k<>length(search)+1) do
begin
str[j]:=search[k];
j:=j+1;
k:=k+1;
end;
str[0]:=chr(j-1);
Val(str,abba,Code);
cut_number:=abba;
end;
procedure read_string(var f:text;i:integer;n:integer;var A:Matrix);
var s:string;
j,k:integer;
begin
k:=1;
readln(f,s);
for j:=1 to n
do A[i,j]:=cut_number(s,k);
end;
procedure read_matrix(var data:text;var n:integer;var A:Matrix);
var s:string;
k:integer;
i:integer;
begin
k:=1;
readln(data,s);
n:=cut_number(s,k);
if n=0 then exit;
for i:=1 to n do
begin
read_string(data,i,n,A);
end;
end;
{//////////////////////////////////////////////////////
Calculating the determinant of the matrix
///////////////////////////////////////////////////////}
{Function of stopping a processing}
Function finish(A:Matrix;n:integer):boolean;
var i,sum:integer;
begin
sum:=0;
for i:=1 to n do
if A[1,i]<>0 then sum:=sum+1;
if (sum=1)or(sum=0) then finish:=true else finish:=false;
end;
{Exchange the rows}
procedure Exchange(x,y:integer; var A:Matrix;n:integer);
var i,buffer:integer;
begin
for i:=1 to n do
begin
buffer:=A[i,x];
A[i,x]:=A[i,y];
A[i,y]:=buffer;
end;
end;
{Sort the first string of the matrix using buble sort}
Procedure Sort(var A:Matrix;n:integer;var s:integer);
var i,j:integer;
begin
for i:=2 to n do
for j:=n downto i do
if abs(A[1,j-1])>abs(A[1,j]) then
begin
Exchange(j-1,j,A,n);
s:=-s;
end;
end;
{Get sign of a number}
function sign(a:integer):integer;
begin
if a>0 then sign:=1 else
if a=0 then sign:=0 else
if a<0 then sign:=-1;
end;
{Subtract the rows using mathematics rules}
Procedure Subtract(x,y:integer;var A:Matrix;n:integer);
var i:integer;
c:integer;
begin
c:=sign(A[1,y])*sign(A[1,x])*abs(A[1,y] div A[1,x]);
for i:=1 to n do
begin
A[i,y]:=A[i,y]-c*A[i,x] ;
end;
end;
{Process the matrix}
Procedure Processing(var A:Matrix;n:integer);
var i,j:integer;
begin
j:=1;
while(A[1,j]=0)
do j:=j+1;
for i:=j+1 to n do Subtract(j,i,A,n);
end;
{Make current minor from the matrix}
procedure GetMatrix(a:Matrix; var b:Matrix; m,i,j:integer);
var ki,kj,di,dj:integer;
begin
di:=0;
for ki:=1 to m-1 do
begin
if (ki=i) then di:=1;
dj:=0;
for kj:=1 to m-1 do
begin
if (kj=j) then dj:=1;
b[ki,kj]:=a[ki+di,kj+dj];
end;
end;
end;
{Main function}
Function Determinant(a:Matrix;n:integer):integer;
var i,j,d,k,d_sign:integer;
b:Matrix;
begin
{set raw data}
d:=0;
k:=1;
d_sign:=1;
{calculating}
if (n=1) then d:=a[1,1]
else
if (n=2) then d:=a[1,1]*a[2,2]-a[2,1]*a[1,2]
else { n>2 }
begin
while (finish(a,n)=false) do
begin
Sort(A,n,d_sign);
Processing(A,n);
end;
for i:=1 to n do
begin
if a[1,i]<>0 then
begin
GetMatrix(a,b,n,1,i);
d:=d+k*a[1,i]*Determinant(b,n-1);
end;
k:=-k;
end;
end;
{last breath}
Determinant:=d_sign*d;
end;
begin
while not eof(input) do begin
if eoln(input) then begin{ this should follow the while sentence with nothing between, just like this }
readln(input); { skip rest of line }
{writeln(output);} { reproduce the eoln character }
continue; { re-test for EOF }
end;
read_matrix(input,n,A);
if n=0 then exit;
writeln(output,Determinant(A,n));
end;
end.

