Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program task23;
- uses
- System.SysUtils;
- Type matrix = array[1..20,1..20] of double;
- procedure ReadFile (var input: text;var a: matrix;var size: integer);
- var
- s: string;
- i, j: integer;
- iscorrect: boolean;
- begin
- repeat
- writeln('Введите название файла с данными:');
- readln(s);
- s := s + '.txt';
- iscorrect := true;
- try
- Assign(input,s);
- Reset(input);
- if not(eof(input)) then
- iscorrect :=true
- else
- begin
- iscorrect := false;
- writeln('Данный файл пуст.Попробуйте другой.');
- end;
- readln(input,size);
- i := 1;
- while not(eof(input)) do
- begin
- j := 1;
- while not(eoln(input)) do
- begin
- read(input,a[i,j]);
- inc(j);
- end;
- inc(i);
- if j <> Size+1 then
- iscorrect := false;
- Readln(input);
- end;
- if i <> Size+1 then
- iscorrect := false;
- except
- iscorrect := false;
- writeln('Название введено неправильно.Попробуйте еще раз.');
- end;
- until iscorrect;
- writeln('Ваша матрица:');
- for i := 1 to size do
- begin
- for j := 1 to size do
- write(' ',a[i,j]:3:1);
- Writeln;
- end;
- end;
- procedure FindMax (var a: matrix; var size: integer; var output: text);
- var
- aMax: double;
- i, j: integer;
- begin
- assign(output,'2222.txt');
- reset(output);
- rewrite(output);
- for i :=1 to size do
- begin
- aMax:=a[i,1];
- for j:=1 to size do
- if aMax<a[i,j] then
- aMax:=a[i,j];
- write(aMax:3:1,' ');
- write(output,aMax:3:1,' ');
- end;
- close(output);
- end;
- var
- input: text;
- output: Text;
- a: matrix;
- size, i: integer;
- aMax: double;
- begin
- writeln('Данная программа строит вектор из наибольших чисел в строках матрицы');
- ReadFile(input,a,size);
- write('Ваш вектор:');
- FindMax(a,size,output);
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement