Напишите программу по которой из текстового файла с именем kvur.txt будут прочитаны три числа: a,b,c - коэффициенты квадратного уравнения затем будут вычислены корни этого уравнения и выведены на экран и в текстовый файл korni.txt. паскаль
Var InFile, OutFile: text; // Вводной и выводной файлы Var a,b,c, D, Result : Integer; Assign(InFile, "C:\kvur.txt"); Assign(OutFile, "C:\korni.txt") Reset(InFile) Read(InFile,a) Read(InFile,b) Read(InFile, c) D = sqr(b) + 4*a*c if D = 0 then Write("Уравнение не имеет корней") Else Append(OutFile) Result:=(-b + sqrt(D)) / 2 * a Write(OutFile,Result) Write("Корень уравнения") WriteLn(Result) if (D>0) then Result:=(-b - sqrt(D)) / 2 * a Write(OutFile, Result) Write("Второй корень уравнения") Write(Result) End; End.
Const nx=30;var i,j,p,n:integer;A:array[1..nx,1..nx] of integer;d,Sn,min:real;begin p:=1;write('Введите размер матрицы');Read(n);for i:=1 to n do beginfor j:=1 to n do beginA[i,j]:=random(3)-2;write(A[i,j]:4);end;writeln;end;writeln;writeln;for i:=1 to n do beginfor j:=1 to n do beginif i = j then begin if A[i,j]<> 0 then p:=p* A[i,j];write(A[i,j]:4);endelse write(' ':4);end;writeln;end;write('p =',p);writeln;writeln;for i:=1 to n do beginfor j:=1 to n do beginif (i= n -j +1) then begin if A[i,j]<> 0 then p:=p* A[i,j];write(A[i,j]:4);endelse write(' ':4);end;writeln;end;write('p =',p);end.
Const n = 5; m = 5; var a:array[1..n,1..m] of integer; i,j,s:integer; begin //Для теста заполним массив сл.числами for i:=1 to n do begin for j:=1 to m do begin a[i,j]:=random(21)-10; write(a[i,j]:4); end; writeln;writeln; end; //сумма всех элементов массива for i:=1 to n do for j:=1 to m do s:=s+a[i,j]; writeln('сумма всех элементов массива: ',s); //сумма каждой строки for i:=1 to n do begin s:=0; for j:=1 to m do begin s:=s+a[i,j]; end; writeln ('Строка: ',i,' сумма:',s); end; end.
Var a,b,c, D, Result : Integer;
Assign(InFile, "C:\kvur.txt");
Assign(OutFile, "C:\korni.txt")
Reset(InFile)
Read(InFile,a)
Read(InFile,b)
Read(InFile, c)
D = sqr(b) + 4*a*c
if D = 0 then
Write("Уравнение не имеет корней")
Else
Append(OutFile)
Result:=(-b + sqrt(D)) / 2 * a
Write(OutFile,Result)
Write("Корень уравнения")
WriteLn(Result)
if (D>0) then
Result:=(-b - sqrt(D)) / 2 * a
Write(OutFile, Result)
Write("Второй корень уравнения")
Write(Result)
End;
End.