]]> ]]>

Квадратное уравнение в Icon

Пример для версий iconc 9.4
procedure main () 
    A := read();
    if A = 0 then {
        write("Not a quadratic equation.");
        return;
    }
    B := read();
    C := read();
    D := B*B - 4*A*C;
    if D = 0 then {
        write("x = ", -B/2/A);
        return;
    }
    if D > 0 then {
        write("x1 = ", (-B+sqrt(D))/2/A);
        write("x2 = ", (-B-sqrt(D))/2/A);
    } else {
        write("x1 = (", -B/2/A, ",", sqrt(-D)/2/A, ")");
        write("x2 = (", -B/2/A, ",", -sqrt(-D)/2/A, ")");
    }
end

Комментарии

]]>

blog comments powered by Disqus

]]>

Работа программистам