function [xneu,Bneu] = simplexschr(x,B,A,b,c)
% Simplex Schritt

n = length(x);
N = setdiff([1:length(x)],B);

X    = A(:,B)\A(:,N); % ineffizient !
barc = c(N)'-c(B)'*X;

if barc>=0
    disp('Die Basis geh�rt zu einer Optimall�sung');
    Bneu = B;
    xneu = x;
else
    [~,cands]=min(barc);
    s = cands(1);
    barAs = X(:,s);
    if barAs<=0
        error('Das Programm ist unbeschr�nkt.');
    end
    barb = A(:,B)\b;
    pA   = find(barAs>0);
    bAp  = barb(pA)./barAs(pA);
    [delta,candr] = min(bAp);
    r    = pA(candr(1));
    xneu = zeros(n,1);
    xneu(B) = x(B)-barAs*delta;
    xneu(N(s)) = delta;
    %x(B(r))=0;
    Bneu = union(setdiff(B,B(r)),N(s));
end

