c = int(input('Enter 2 to start'))
while c != 1:
import math as m
a = int(input('Write a: '))
b = int(input('Write b: '))
c = int(input('Write c: '))
D = (b ** 2) - (4 * a * c)
print ('D =',D)
if D > 0:
print('D > 0')
x = (-b + (m.sqrt(D))) / (2 * a)
x1 = (-b - (m.sqrt(D))) / (2 * a)
print ('x1 =',x)
print ('x2 =',x1)
elif D == 0:
print('D = 0')
x = -b / (2 * a)
print ('x =',x)
else:
print('D < 0')
print ('No roots')
c = int(input('Enter 1 to quit or 2 to repeat'))
===== PascalABC.NET =====
function S(a: array[,] of integer) :=
a.Cols.Where(p -> p.All(q -> q >= 0)).SelectMany(p -> p).Sum;
function M(a: array[,] of integer): integer;
begin
var n := a.RowCount;
Result := integer.MaxValue;
var s: integer;
for var i := 0 to n - 2 do
s := 0;
for var j := 0 to i do
s += Abs(a[i - j, j]);
if s < Result then
Result := s
end;
for var j := 1 to n - 1 do
for var i := n - 1 downto j do
s += Abs(a[i, n - i + j - 1]);
end
var n := ReadInteger('n =');
var a := MatrRandom(n, n, -10, 30);
a.Println;
S(a).Println;
M(a).Println;
end.
c = int(input('Enter 2 to start'))
while c != 1:
import math as m
a = int(input('Write a: '))
b = int(input('Write b: '))
c = int(input('Write c: '))
D = (b ** 2) - (4 * a * c)
print ('D =',D)
if D > 0:
print('D > 0')
x = (-b + (m.sqrt(D))) / (2 * a)
x1 = (-b - (m.sqrt(D))) / (2 * a)
print ('x1 =',x)
print ('x2 =',x1)
elif D == 0:
print('D = 0')
x = -b / (2 * a)
print ('x =',x)
else:
print('D < 0')
print ('No roots')
c = int(input('Enter 1 to quit or 2 to repeat'))
===== PascalABC.NET =====
function S(a: array[,] of integer) :=
a.Cols.Where(p -> p.All(q -> q >= 0)).SelectMany(p -> p).Sum;
function M(a: array[,] of integer): integer;
begin
var n := a.RowCount;
Result := integer.MaxValue;
var s: integer;
for var i := 0 to n - 2 do
begin
s := 0;
for var j := 0 to i do
s += Abs(a[i - j, j]);
if s < Result then
Result := s
end;
for var j := 1 to n - 1 do
begin
s := 0;
for var i := n - 1 downto j do
s += Abs(a[i, n - i + j - 1]);
if s < Result then
Result := s
end
end;
begin
var n := ReadInteger('n =');
var a := MatrRandom(n, n, -10, 30);
a.Println;
S(a).Println;
M(a).Println;
end.