function [x,k,erro]=gauss(A,b,x0,tol)
n=length(A);
%%%%%%%%%%%%%Matriz Iterativa%%%%%%%%%%%
n=length(A);
for i=1:n
for j=1:n
if i==j
F(i,j)=0;
else
F(i,j)=-A(i,j)/A(i,i);
d(i,1)=b(i,1)/A(i,i);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
k=0; erro=tol+1;
x=x0;
while erro>tol
for i=1:n
x(i,1)=F(i,:)*x+d(i,1);
end
erro=max(abs(x-x0));
x0=x;
k=k+1;
end
end