Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. program task23;
  2. uses
  3. System.SysUtils;
  4. Type matrix = array[1..20,1..20] of double;
  5. procedure ReadFile (var input: text;var a: matrix;var size: integer);
  6. var
  7. s: string;
  8. i, j: integer;
  9. iscorrect: boolean;
  10. begin
  11. repeat
  12. writeln('Введите название файла с данными:');
  13. readln(s);
  14. s := s + '.txt';
  15. iscorrect := true;
  16. try
  17. Assign(input,s);
  18. Reset(input);
  19. if not(eof(input)) then
  20. iscorrect :=true
  21. else
  22. begin
  23. iscorrect := false;
  24. writeln('Данный файл пуст.Попробуйте другой.');
  25. end;
  26. readln(input,size);
  27. i := 1;
  28. while not(eof(input)) do
  29. begin
  30. j := 1;
  31. while not(eoln(input)) do
  32. begin
  33. read(input,a[i,j]);
  34. inc(j);
  35. end;
  36. inc(i);
  37. if j <> Size+1 then
  38. iscorrect := false;
  39. Readln(input);
  40. end;
  41. if i <> Size+1 then
  42. iscorrect := false;
  43. except
  44. iscorrect := false;
  45. writeln('Название введено неправильно.Попробуйте еще раз.');
  46. end;
  47. until iscorrect;
  48.  
  49.  
  50. writeln('Ваша матрица:');
  51. for i := 1 to size do
  52. begin
  53. for j := 1 to size do
  54. write(' ',a[i,j]:3:1);
  55. Writeln;
  56. end;
  57. end;
  58. procedure FindMax (var a: matrix; var size: integer; var output: text);
  59. var
  60. aMax: double;
  61. i, j: integer;
  62. begin
  63. assign(output,'2222.txt');
  64. reset(output);
  65. rewrite(output);
  66. for i :=1 to size do
  67. begin
  68. aMax:=a[i,1];
  69. for j:=1 to size do
  70. if aMax<a[i,j] then
  71. aMax:=a[i,j];
  72. write(aMax:3:1,' ');
  73. write(output,aMax:3:1,' ');
  74. end;
  75. close(output);
  76. end;
  77. var
  78. input: text;
  79. output: Text;
  80. a: matrix;
  81. size, i: integer;
  82. aMax: double;
  83. begin
  84. writeln('Данная программа строит вектор из наибольших чисел в строках матрицы');
  85. ReadFile(input,a,size);
  86. write('Ваш вектор:');
  87. FindMax(a,size,output);
  88. readln;
  89. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement