klasscho

Untitled

Nov 17th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. function ReadMatrix (var Matrixx: MatrixType; FName: string);
  2. var
  3. MyFileInPut: TextFile;
  4. i, j, w: Integer;
  5. Arr: array of array of Integer;
  6. begin
  7. AssignFile(MyFileInPut, FName);
  8. Reset(MyFileInPut);
  9. i := -1;
  10. while not Eof(MyFileInPut) do begin
  11. Inc(i);
  12. SetLength(arr, i + 1);
  13. j:= -1;
  14. while not Eoln(MyFileInPut) do begin
  15. Inc(j);
  16. SetLength(arr[i], j + 1);
  17. Read(MyFileInPut, arr[i, j]);
  18. end;
  19. Readln(MyFileInPut);
  20. end;
  21. CloseFile(MyFileInPut);
  22. end;
  23.  
  24. function Average (MatrEl: array of array of Integer);
  25. var
  26. Sum, Amount, i, j, n: Integer;
  27. begin
  28. Sum := 0;
  29. Amount := 0;
  30. for i := 0 to n - 1 do
  31. if MatrEl[i, j] > 0 then
  32. begin
  33. Sum := Sum + MatrEl[i, j];
  34. Inc(Amount);
  35. end;
  36. Average := Sum/Amount;
  37. end;
Advertisement
Add Comment
Please, Sign In to add comment