Hello guy,
is here someone who can help me with programme about Gauss or Gauss Jordan elimination? I need it for calculating of system with linear equations.

Thank you

Help with the algorithm..

Alright, have you tried writing any code yet? If so, please post it.

Starting at the beginning: How are you representing matrices?

I have procedure which takes data from a file and writes them then I have problem with main procedure of Gauss :/ I will post it tomorrow now I need to go sleep gn :)

Ok I found I did it bad... Now Im trying to do it right just have 2 days for it... Any help will 100% help me with it..

I actually did that but Im not sure if its 100% right..

program gauss;
uses crt;
const max=10;
type matrix = array[1..max,1..max] of real;
var a:matrix;
    i,j,f,g,e,N,M:integer;
    y:real;
    c,d:boolean;
    inFile : text;
    inFileName : string;

procedure readFile(var A : matrix); 
  var i,j : integer;
   begin  i := 1; j := 1;
     while not eof(inFile) do
     begin 
        j := 1;
       while not eoln(inFile) do
         begin
           read(inFile,a[i,j]);
           inc(j);
         end;
         readln(inFile);
         inc(i);
     end;
     close(inFile);
   end;

procedure zero (m:integer; var A:matrix);
  var n,k:integer;
      z:real;
begin
  n:=m;k:=m;
  while (A[m,n]=0) and (M<=N) do   
    begin
      m:=m+1;
      if A[m,n]<>0 then          
        for n:=1 to N+1 do
          begin
            z:=A[m,n];           
            A[m,n]:=A[k,n];
            A[k,n]:=z;
          end;
    end;
end;

begin
writeln('Name of the input file?: ');
 readln(inFileName);
 assign(inFile,inFileName);
 reset(inFile);
 readln(inFile,N,M);
  d:=false;
  readFile(a);               
  for i:=1 to N-1 do
    begin
      zero(i,a);           
      for e:=1 to N-i do
        begin
          if a[i+e,i]<>0 then
            begin
              y:=a[i+e,i]/a[i,i]*(-1);   
                for j:=1 to n+1 do
                  begin
                    a[i,j]:=a[i,j]*y;
                    a[i+e,j]:=a[i+e,j]+a[i,j];
                  end;
            end;
        end;
      for f:=i to n do   
       begin
         c:=false;
         for g:=1 to N do c:=(a[f,g]<>0) or c;
          if not(c) then d:=a[f,N+1]=0;
       end;
    end;
    if c then
    begin
      for j:=n downto 1 do
        begin
          for e:=j+1 to n do a[j,N+1]:=a[j,N+1]-a[j,e]; 
          a[N+1,j]:=a[j,N+1]/a[j,j];                   
          for i:=1 to j-1 do a[i,j]:=a[i,j]*a[N+1,j]; 
        end;
      for j:=1 to n do
      writeln('x',j,'= ',a[N+1,j]:4:2);         
    end
       else if d then writeln('The equation has infinitely solutions !')
                 else writeln('The equation has no solution !');
  repeat until keypressed;
end.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.