Ссылка на объект не указывает на экземпляр объекта. program MatrixLinkedList;
type
MatrixElement = record
value: real;
end;
ListNode = record
row: integer;
matrixElement: MatrixElement;
next: ^ListNode;
end;
var
n, m, i, j: integer;
matrix: array of array of MatrixElement;
head, temp, tempPrev, newNode: ^ListNode;
ass:char;
begin
write('Enter number of rows : ');
readln;
write('Enter number of columns (m): ');
readln(m);
//SetLength(matrix, n, m);
for i := 0 to n - 1 do
begin
for j := 0 to m - 1 do
begin
write('Enter value for matrix[', i + 1, '][', j + 1, ']: ');
readln(matrix[i,j].value);
end;
end;
write('a or b:');
readln(ass);
if (ass='a') then
begin
for i := 0 to n - 1 do
begin
temp := head;
tempPrev := nil;
while (temp nil) and (temp^.matrixElement.value < matrix[i,0].value) do
begin
tempPrev := temp;
temp := temp^.next;
end;
new(newNode);
newNode^.row := i;
newNode^.matrixElement := matrix[i,0];
if temp = head then
begin
newNode^.next := head;
head := newNode;
end
else
begin
newNode^.next := temp;
if tempPrev nil then
begin
tempPrev^.next := newNode;
end;
end;
end;
end;
if (ass='b') then
begin
for i := 0 to n - 1 do
begin
temp := head;
tempPrev := nil;
while (temp nil) and (temp^.matrixElement.value >= matrix[i,0].value) do
begin
tempPrev := temp;
temp := temp^.next;
end;
new(newNode);
newNode^.row := i;
newNode^.matrixElement := matrix[i,0];
if temp = head then
begin
newNode^.next := head;
head := newNode;
end
else
begin
newNode^.next := temp;
if tempPrev nil then
begin
tempPrev^.next := newNode;
end;
end;
end;
end;
end.
type
MatrixElement = record
value: real;
end;
ListNode = record
row: integer;
matrixElement: MatrixElement;
next: ^ListNode;
end;
var
n, m, i, j: integer;
matrix: array of array of MatrixElement;
head, temp, tempPrev, newNode: ^ListNode;
ass:char;
begin
write('Enter number of rows : ');
readln;
write('Enter number of columns (m): ');
readln(m);
//SetLength(matrix, n, m);
for i := 0 to n - 1 do
begin
for j := 0 to m - 1 do
begin
write('Enter value for matrix[', i + 1, '][', j + 1, ']: ');
readln(matrix[i,j].value);
end;
end;
write('a or b:');
readln(ass);
if (ass='a') then
begin
for i := 0 to n - 1 do
begin
temp := head;
tempPrev := nil;
while (temp nil) and (temp^.matrixElement.value < matrix[i,0].value) do
begin
tempPrev := temp;
temp := temp^.next;
end;
new(newNode);
newNode^.row := i;
newNode^.matrixElement := matrix[i,0];
if temp = head then
begin
newNode^.next := head;
head := newNode;
end
else
begin
newNode^.next := temp;
if tempPrev nil then
begin
tempPrev^.next := newNode;
end;
end;
end;
end;
if (ass='b') then
begin
for i := 0 to n - 1 do
begin
temp := head;
tempPrev := nil;
while (temp nil) and (temp^.matrixElement.value >= matrix[i,0].value) do
begin
tempPrev := temp;
temp := temp^.next;
end;
new(newNode);
newNode^.row := i;
newNode^.matrixElement := matrix[i,0];
if temp = head then
begin
newNode^.next := head;
head := newNode;
end
else
begin
newNode^.next := temp;
if tempPrev nil then
begin
tempPrev^.next := newNode;
end;
end;
end;
end;
end.