Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. program Project3;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. {$R *.res}
  6.  
  7. uses
  8. System.SysUtils;
  9.  
  10. type
  11. TMatrix = Array of Array of Integer;
  12.  
  13. procedure FillMatrix(var Matrix: TMatrix; var Size: Integer);
  14. var
  15. FirstRow: Array of Integer;
  16. i, j, k, Count: Integer;
  17. IsConcident: Boolean;
  18.  
  19. begin
  20. Write('Enter the size: ');
  21. ReadLn(Size);
  22. SetLength(Matrix, Size, Size);
  23. Size := Size - 1;
  24. WriteLn('Fill the Matrix');
  25. for i := 0 to Size do
  26. for j := 0 to Size do
  27. begin
  28. Write('А[', i, ', ', j, '] = ');
  29. ReadLn(Matrix[i, j]);
  30. end;
  31. end;
  32.  
  33. procedure CountMatches(Matrix: TMatrix; Size: Integer; var Count: Integer);
  34. var
  35. Matches: Boolean;
  36. i,j,k: Integer;
  37. FirstRow: Array of Integer;
  38. begin
  39. SetLength(FirstRow, Size);
  40. for i := 0 to Size do
  41. FirstRow[i] := Matrix[0, i];
  42. for i := 0 to Size do
  43. begin
  44. Matches := True;
  45. for j := 0 to Size do
  46. for k := 0 to Size do
  47. if Matrix[i, j] = FirstRow[k] then
  48. Matches := False;
  49. if Matches then
  50. Inc(Count);
  51. end;
  52. end;
  53.  
  54. procedure Output(Count: Integer);
  55. begin
  56. Writeln('Number of rows without matches', Count);
  57. end;
  58.  
  59. procedure Main();
  60. var
  61. Matrix: TMatrix;
  62. Count, Size: Integer;
  63. begin
  64. FillMatrix(Matrix, Size);
  65. CountMatches(Matrix, Size, Count);
  66. Output(Count);
  67. Readln;
  68. Readln;
  69. end;
  70.  
  71. begin
  72. Main();
  73. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement