Ошибка 216 паскаль

Free pascal runtime error 216 Applications generated by Free Pascal might generate run-time errors when certain abnormal conditions are detected in the application. This appendix lists the possible run-time errors and gives information on why they might be produced. 1 Invalid function number An invalid operating system call was attempted. 2 File not found […]

Содержание

  1. Free pascal runtime error 216
  2. Free pascal runtime error 216
  3. Re: Linux, runtime error 216
  4. Re: Linux, runtime error 216
  5. Re: Linux, runtime error 216
  6. Re: Linux, runtime error 216
  7. Re: Linux, runtime error 216
  8. Re: Linux, runtime error 216
  9. Re: Linux, runtime error 216
  10. Re: Linux, runtime error 216
  11. Re: Linux, runtime error 216
  12. Re: Linux, runtime error 216
  13. Кто сейчас на конференции
  14. Free pascal runtime error 216
  15. Re: Linux, runtime error 216
  16. Re: Linux, runtime error 216
  17. Re: Linux, runtime error 216
  18. Re: Linux, runtime error 216
  19. Re: Linux, runtime error 216
  20. Re: Linux, runtime error 216
  21. Re: Linux, runtime error 216
  22. Re: Linux, runtime error 216
  23. Re: Linux, runtime error 216
  24. Re: Linux, runtime error 216
  25. Кто сейчас на конференции
  26. Free pascal runtime error 216
  27. Re: Linux, runtime error 216
  28. Re: Linux, runtime error 216
  29. Re: Linux, runtime error 216
  30. Re: Linux, runtime error 216
  31. Re: Linux, runtime error 216
  32. Re: Linux, runtime error 216
  33. Re: Linux, runtime error 216
  34. Re: Linux, runtime error 216
  35. Re: Linux, runtime error 216
  36. Re: Linux, runtime error 216
  37. Кто сейчас на конференции
  38. Free pascal runtime error 216
  39. Re: Linux, runtime error 216
  40. Re: Linux, runtime error 216
  41. Re: Linux, runtime error 216
  42. Re: Linux, runtime error 216
  43. Re: Linux, runtime error 216
  44. Re: Linux, runtime error 216
  45. Re: Linux, runtime error 216
  46. Re: Linux, runtime error 216
  47. Re: Linux, runtime error 216
  48. Re: Linux, runtime error 216
  49. Кто сейчас на конференции

Free pascal runtime error 216

Applications generated by Free Pascal might generate run-time errors when certain abnormal conditions are detected in the application. This appendix lists the possible run-time errors and gives information on why they might be produced. 1 Invalid function number An invalid operating system call was attempted. 2 File not found Reported when trying to erase, rename or open a non-existent file. 3 Path not found Reported by the directory handling routines when a path does not exist or is invalid. Also reported when trying to access a non-existent file. 4 Too many open files The maximum number of files currently opened by your process has been reached. Certain operating systems limit the number of files which can be opened concurrently, and this error can occur when this limit has been reached. 5 File access denied Permission to access the file is denied. This error might be caused by one of several reasons:

  • Trying to open for writing a file which is read-only, or which is actually a directory.
  • File is currently locked or used by another process.
  • Trying to create a new file, or directory while a file or directory of the same name already exists.
  • Trying to read from a file which was opened in write-only mode.
  • Trying to write from a file which was opened in read-only mode.
  • Trying to remove a directory or file while it is not possible.
  • No permission to access the file or directory.

6 Invalid file handle If this happens, the file variable you are using is trashed; it indicates that your memory is corrupted. 12 Invalid file access code Reported when a reset or rewrite is called with an invalid FileMode value. 15 Invalid drive number The number given to the Getdir or ChDir function specifies a non-existent disk. 16 Cannot remove current directory Reported when trying to remove the currently active directory. 17 Cannot rename across drives You cannot rename a file such that it would end up on another disk or partition. 100 Disk read error An error occurred when reading from disk. Typically happens when you try to read past the end of a file. 101 Disk write error Reported when the disk is full, and you’re trying to write to it. 102 File not assigned This is reported by Reset , Rewrite , Append , Rename and Erase , if you call them with an unassigned file as a parameter. 103 File not open Reported by the following functions : Close, Read, Write, Seek, EOf, FilePos, FileSize, Flush, BlockRead, and BlockWrite if the file is not open. 104 File not open for input Reported by Read, BlockRead, Eof, Eoln, SeekEof or SeekEoln if the file is not opened with Reset . 105 File not open for output Reported by write if a text file isn’t opened with Rewrite . 106 Invalid numeric format Reported when a non-numeric value is read from a text file, and a numeric value was expected. 107 Invalid enumeration Reported when a text representation of an enumerated constant cannot be created in a call to str or write(ln). 150 Disk is write-protected (Critical error) 151 Bad drive request struct length (Critical error) 152 Drive not ready (Critical error) 154 CRC error in data (Critical error) 156 Disk seek error (Critical error) 157 Unknown media type (Critical error) 158 Sector Not Found (Critical error) 159 Printer out of paper (Critical error) 160 Device write fault (Critical error) 161 Device read fault (Critical error) 162 Hardware failure (Critical error) 200 Division by zero The application attempted to divide a number by zero. 201 Range check error If you compiled your program with range checking on, then you can get this error in the following cases: 1. An array was accessed with an index outside its declared range. 2. Trying to assign a value to a variable outside its range (for instance an enumerated type). 202 Stack overflow error The stack has grown beyond its maximum size (in which case the size of local variables should be reduced to avoid this error), or the stack has become corrupt. This error is only reported when stack checking is enabled. 203 Heap overflow error The heap has grown beyond its boundaries. This is caused when trying to allocate memory explicitly with New , GetMem or ReallocMem , or when a class or object instance is created and no memory is left. Please note that, by default, Free Pascal provides a growing heap, i.e. the heap will try to allocate more memory if needed. However, if the heap has reached the maximum size allowed by the operating system or hardware, then you will get this error. 204 Invalid pointer operation You will get this in several cases:

  • if you call Dispose or Freemem with an invalid pointer
  • in case New or GetMem is called, and there is no more memory available. The behavior in this case depends on the setting of ReturnNilIfGrowHeapFails . If it is True , then Nil is returned. if False , then runerror 204 is raised.

205 Floating point overflow You are trying to use or produce real numbers that are too large. 206 Floating point underflow You are trying to use or produce real numbers that are too small. 207 Invalid floating point operation Can occur if you try to calculate the square root or logarithm of a negative number. 210 Object not initialized When compiled with range checking on, a program will report this error if you call a virtual method without having called its object’s constructor. 211 Call to abstract method Your program tried to execute an abstract virtual method. Abstract methods should be overridden, and the overriding method should be called. 212 Stream registration error This occurs when an invalid type is registered in the objects unit. 213 Collection index out of range You are trying to access a collection item with an invalid index ( objects unit). 214 Collection overflow error The collection has reached its maximal size, and you are trying to add another element ( objects unit). 215 Arithmetic overflow error This error is reported when the result of an arithmetic operation is outside of its supported range. Contrary to Turbo Pascal, this error is only reported for 32-bit or 64-bit arithmetic overflows. This is due to the fact that everything is converted to 32-bit or 64-bit before doing the actual arithmetic operation. 216 General Protection fault The application tried to access invalid memory space. This can be caused by several problems: 1. Dereferencing a nil pointer. 2. Trying to access memory which is out of bounds (for example, calling move with an invalid length). 217 Unhandled exception occurred An exception occurred, and there was no exception handler present. The sysutils unit installs a default exception handler which catches all exceptions and exits gracefully. 218 Invalid value specified Error 218 occurs when an invalid value was specified to a system call, for instance when specifying a negative value to a seek() call. 219 Invalid typecast

Thrown when an invalid typecast is attempted on a class using the as operator. This error is also thrown when an object or class is typecast to an invalid class or object and a virtual method of that class or object is called. This last error is only detected if the -CR compiler option is used. 222 Variant dispatch error No dispatch method to call from variant. 223 Variant array create The variant array creation failed. Usually when there is not enough memory. 224 Variant is not an array This error occurs when a variant array operation is attempted on a variant which is not an array. 225 Var Array Bounds check error This error occurs when a variant array index is out of bounds. 227 Assertion failed error An assertion failed, and no AssertErrorProc procedural variable was installed. 229 Safecall error check This error occurs is a safecall check fails, and no handler routine is available. 231 Exception stack corrupted This error occurs when the exception object is retrieved and none is available. 232 Threads not supported Thread management relies on a separate driver on some operating systems (notably, Unixes). The unit with this driver needs to be specified on the uses clause of the program, preferably as the first unit ( cthreads on unix).

Источник

Free pascal runtime error 216

Rasmussen » 27.10.2012 18:39:55

Всем добра!
Случилась такая беда — компилятор отказался запускаться, ссылаясь на эту ошибку.
Причём ругается при попытке скомпилировать абсолютно любую программу и при попытке войти в IDE.
Честно говоря, я даже малейшего представления не имею, что могло послужить первоисточником проблемы.

Полная переустановка не возымела результата. Версия с сайта (с install.sh в архиве) даёт аналогичный результат.

Дистрибутив — ArchLinux x86.

Взываю к вашей помощи!

Re: Linux, runtime error 216

Ism » 27.10.2012 19:17:36

Re: Linux, runtime error 216

Rasmussen » 27.10.2012 20:07:29

[rasmussen@acm rasmussen]$ fpc
Runtime error 216 at $000000000043F876
$000000000043F876
$0000000000400180

[rasmussen@acm rasmussen]$ fp
Runtime error 216 at $00000000004C3EF5
$00000000004C3EF5

[rasmussen@acm rasmussen]$ cd pascal/

[rasmussen@acm pascal]$ fpc if-then.pas
Runtime error 216 at $000000000043F876
$000000000043F876
$0000000000400180

Re: Linux, runtime error 216

Максим » 27.10.2012 23:50:48

Прям вот так и отказался, ни с того, ни с сего?

Вангую, что криво накатили обновление Арчика.

Re: Linux, runtime error 216

Vadim » 28.10.2012 10:10:09

Re: Linux, runtime error 216

Rasmussen » 28.10.2012 22:38:22

Re: Linux, runtime error 216

Vadim » 29.10.2012 11:54:53

Re: Linux, runtime error 216

Rasmussen » 29.10.2012 15:38:10

Re: Linux, runtime error 216

Vadim » 29.10.2012 15:48:46

Re: Linux, runtime error 216

Rasmussen » 29.10.2012 22:51:40

Re: Linux, runtime error 216

Сквозняк » 02.11.2012 00:52:12

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2

Источник

Free pascal runtime error 216

Rasmussen » 27.10.2012 18:39:55

Всем добра!
Случилась такая беда — компилятор отказался запускаться, ссылаясь на эту ошибку.
Причём ругается при попытке скомпилировать абсолютно любую программу и при попытке войти в IDE.
Честно говоря, я даже малейшего представления не имею, что могло послужить первоисточником проблемы.

Полная переустановка не возымела результата. Версия с сайта (с install.sh в архиве) даёт аналогичный результат.

Дистрибутив — ArchLinux x86.

Взываю к вашей помощи!

Re: Linux, runtime error 216

Ism » 27.10.2012 19:17:36

Re: Linux, runtime error 216

Rasmussen » 27.10.2012 20:07:29

[rasmussen@acm rasmussen]$ fpc
Runtime error 216 at $000000000043F876
$000000000043F876
$0000000000400180

[rasmussen@acm rasmussen]$ fp
Runtime error 216 at $00000000004C3EF5
$00000000004C3EF5

[rasmussen@acm rasmussen]$ cd pascal/

[rasmussen@acm pascal]$ fpc if-then.pas
Runtime error 216 at $000000000043F876
$000000000043F876
$0000000000400180

Re: Linux, runtime error 216

Максим » 27.10.2012 23:50:48

Прям вот так и отказался, ни с того, ни с сего?

Вангую, что криво накатили обновление Арчика.

Re: Linux, runtime error 216

Vadim » 28.10.2012 10:10:09

Re: Linux, runtime error 216

Rasmussen » 28.10.2012 22:38:22

Re: Linux, runtime error 216

Vadim » 29.10.2012 11:54:53

Re: Linux, runtime error 216

Rasmussen » 29.10.2012 15:38:10

Re: Linux, runtime error 216

Vadim » 29.10.2012 15:48:46

Re: Linux, runtime error 216

Rasmussen » 29.10.2012 22:51:40

Re: Linux, runtime error 216

Сквозняк » 02.11.2012 00:52:12

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2

Источник

Free pascal runtime error 216

Rasmussen » 27.10.2012 18:39:55

Всем добра!
Случилась такая беда — компилятор отказался запускаться, ссылаясь на эту ошибку.
Причём ругается при попытке скомпилировать абсолютно любую программу и при попытке войти в IDE.
Честно говоря, я даже малейшего представления не имею, что могло послужить первоисточником проблемы.

Полная переустановка не возымела результата. Версия с сайта (с install.sh в архиве) даёт аналогичный результат.

Дистрибутив — ArchLinux x86.

Взываю к вашей помощи!

Re: Linux, runtime error 216

Ism » 27.10.2012 19:17:36

Re: Linux, runtime error 216

Rasmussen » 27.10.2012 20:07:29

[rasmussen@acm rasmussen]$ fpc
Runtime error 216 at $000000000043F876
$000000000043F876
$0000000000400180

[rasmussen@acm rasmussen]$ fp
Runtime error 216 at $00000000004C3EF5
$00000000004C3EF5

[rasmussen@acm rasmussen]$ cd pascal/

[rasmussen@acm pascal]$ fpc if-then.pas
Runtime error 216 at $000000000043F876
$000000000043F876
$0000000000400180

Re: Linux, runtime error 216

Максим » 27.10.2012 23:50:48

Прям вот так и отказался, ни с того, ни с сего?

Вангую, что криво накатили обновление Арчика.

Re: Linux, runtime error 216

Vadim » 28.10.2012 10:10:09

Re: Linux, runtime error 216

Rasmussen » 28.10.2012 22:38:22

Re: Linux, runtime error 216

Vadim » 29.10.2012 11:54:53

Re: Linux, runtime error 216

Rasmussen » 29.10.2012 15:38:10

Re: Linux, runtime error 216

Vadim » 29.10.2012 15:48:46

Re: Linux, runtime error 216

Rasmussen » 29.10.2012 22:51:40

Re: Linux, runtime error 216

Сквозняк » 02.11.2012 00:52:12

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2

Источник

Free pascal runtime error 216

Rasmussen » 27.10.2012 18:39:55

Всем добра!
Случилась такая беда — компилятор отказался запускаться, ссылаясь на эту ошибку.
Причём ругается при попытке скомпилировать абсолютно любую программу и при попытке войти в IDE.
Честно говоря, я даже малейшего представления не имею, что могло послужить первоисточником проблемы.

Полная переустановка не возымела результата. Версия с сайта (с install.sh в архиве) даёт аналогичный результат.

Дистрибутив — ArchLinux x86.

Взываю к вашей помощи!

Re: Linux, runtime error 216

Ism » 27.10.2012 19:17:36

Re: Linux, runtime error 216

Rasmussen » 27.10.2012 20:07:29

[rasmussen@acm rasmussen]$ fpc
Runtime error 216 at $000000000043F876
$000000000043F876
$0000000000400180

[rasmussen@acm rasmussen]$ fp
Runtime error 216 at $00000000004C3EF5
$00000000004C3EF5

[rasmussen@acm rasmussen]$ cd pascal/

[rasmussen@acm pascal]$ fpc if-then.pas
Runtime error 216 at $000000000043F876
$000000000043F876
$0000000000400180

Re: Linux, runtime error 216

Максим » 27.10.2012 23:50:48

Прям вот так и отказался, ни с того, ни с сего?

Вангую, что криво накатили обновление Арчика.

Re: Linux, runtime error 216

Vadim » 28.10.2012 10:10:09

Re: Linux, runtime error 216

Rasmussen » 28.10.2012 22:38:22

Re: Linux, runtime error 216

Vadim » 29.10.2012 11:54:53

Re: Linux, runtime error 216

Rasmussen » 29.10.2012 15:38:10

Re: Linux, runtime error 216

Vadim » 29.10.2012 15:48:46

Re: Linux, runtime error 216

Rasmussen » 29.10.2012 22:51:40

Re: Linux, runtime error 216

Сквозняк » 02.11.2012 00:52:12

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2

Источник

Модератор: Модераторы

Linux, runtime error 216

Всем добра!
Случилась такая беда — компилятор отказался запускаться, ссылаясь на эту ошибку.
Причём ругается при попытке скомпилировать абсолютно любую программу и при попытке войти в IDE.
Честно говоря, я даже малейшего представления не имею, что могло послужить первоисточником проблемы.

Полная переустановка не возымела результата. Версия с сайта (с install.sh в архиве) даёт аналогичный результат.

Дистрибутив — ArchLinux x86.

Взываю к вашей помощи!

Rasmussen
новенький
 
Сообщения: 13
Зарегистрирован: 02.07.2012 21:33:54

Re: Linux, runtime error 216

Сообщение Ism » 27.10.2012 19:17:36

Ему чегото не хватает, что в командной строке говорит ?

Ism
энтузиаст
 
Сообщения: 908
Зарегистрирован: 06.04.2007 17:36:08

Re: Linux, runtime error 216

Сообщение Rasmussen » 27.10.2012 20:07:29

Консоль, к сожалению, ничего информативного не несёт:

[rasmussen@acm rasmussen]$ fpc
Runtime error 216 at $000000000043F876
$000000000043F876
$0000000000400180

[rasmussen@acm rasmussen]$ fp

Runtime error 216 at $00000000004C3EF5
$00000000004C3EF5

[rasmussen@acm rasmussen]$ cd pascal/

[rasmussen@acm pascal]$ fpc if-then.pas
Runtime error 216 at $000000000043F876
$000000000043F876
$0000000000400180

Rasmussen
новенький
 
Сообщения: 13
Зарегистрирован: 02.07.2012 21:33:54

Re: Linux, runtime error 216

Сообщение Максим » 27.10.2012 23:50:48

Прям вот так и отказался, ни с того, ни с сего? :mrgreen:

Вангую, что криво накатили обновление Арчика.

Аватара пользователя
Максим
энтузиаст
 
Сообщения: 597
Зарегистрирован: 27.07.2007 01:51:43
Откуда: Москва

Re: Linux, runtime error 216

Сообщение Vadim » 28.10.2012 10:10:09

Rasmussen
А Вы из AUR пробовали FPC устанавливать? Там версия тоже свежая лежит — 2.6

Vadim
долгожитель
 
Сообщения: 4112
Зарегистрирован: 05.10.2006 08:52:59
Откуда: Красноярск

Re: Linux, runtime error 216

Сообщение Rasmussen » 28.10.2012 22:38:22

Единственно событие, которое предшетствовало отказу в работе — правка rc.conf под новые требования. Я тогда неверно порписал локаль и после такого впервые заметил проблему.
Проблема в том, что в АУРе он собирается из svn, а при сборке этой версии необходим уже усановленный компилятор.
Между молотом и наковальней, словом!

Rasmussen
новенький
 
Сообщения: 13
Зарегистрирован: 02.07.2012 21:33:54

Re: Linux, runtime error 216

Сообщение Vadim » 29.10.2012 11:54:53

Rasmussen
А Вы по какой ссылке качали FPC с сайта?
У Вас 32-ух или 64-ёх разрядная ОС?

Vadim
долгожитель
 
Сообщения: 4112
Зарегистрирован: 05.10.2006 08:52:59
Откуда: Красноярск


Re: Linux, runtime error 216

Сообщение Vadim » 29.10.2012 15:48:46

Rasmussen
Качали 32-ух битный FPC или 64-ёх битный?

Vadim
долгожитель
 
Сообщения: 4112
Зарегистрирован: 05.10.2006 08:52:59
Откуда: Красноярск

Re: Linux, runtime error 216

Сообщение Rasmussen » 29.10.2012 22:51:40

Пробовал оба — оба кажут Runtime error 216 и, как я понял, адрес на сегмент оперативной памяти.

Rasmussen
новенький
 
Сообщения: 13
Зарегистрирован: 02.07.2012 21:33:54

Re: Linux, runtime error 216

Сообщение Сквозняк » 02.11.2012 00:52:12

Если есть возможность, то надо собрать в другой системе бинарник с ключом -Xm и после выпадения ошибки 216 посмотреть по *.map файлу в какой процедуре случилась ошибка. В принципе нужно хакнуть файл Makefile и вписать туда опцию компилятора — очень удобная система сборки :mrgreen:

Сквозняк
энтузиаст
 
Сообщения: 1006
Зарегистрирован: 29.06.2006 22:08:32


Вернуться в Free Pascal Compiler

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 12

uses crt;
type
breed=(dog,pudel,bolonka,kolli,rotv);
gender=(f,m);
obj=record
p1:byte;
p2:breed;
p3:string[10];
p4:byte;
p5:gender;
p6:string[10];
end;
ff=file of obj;
mas=array[1..100] of ^obj;
var
f1:ff;
i,j,n,nh,nc:byte;
a,ah,am:mas;
dub:obj;
fl:boolean;
procedure input(var fx:ff; n:byte);
var
i,j:byte;
x:obj;
begin
reset(fx);
for j:=1 to n do
begin
with x do
begin
writeln('Type for ',j,' dog');
writeln('Type Club Number');
readln(p1);
writeln('Type breed: 0-Dog, 1-Pudel, 2-Bolonka, 3-Kolli, 4-Rotveiller');
readln(i);
p2:=breed(i);
writeln('Type Name');
readln(p3);
writeln('Type age');
readln(p4);
writeln('Type gender 0-f,1-m');
readln(i);
p5:=gender(i);
writeln('Type owner"s Surname');
readln(p6);
end;
write(fx,x);
end;
end;
procedure output(var x:mas;n:byte);
var i:byte;
begin
for i:=1 to n do
with x[i]^ do
begin
writeln;
writeln('DATA for ',i,' dog');
write('Club Number: ');
write(p1,'; ');
write('Breed: ');
case p2 of
dog:write('Dog');
pudel:write('Pudel');
bolonka:write('Bolonka');
kolli:write('Kolli');
rotv:write('Rotveiller');
end;
write('; ');
write('Name: ');
write(p3,'; ');
write('Age: ');
write(p4,'; ');
write('Gender: ');
case p5 of
m:write('male; ');
f:write('female; ');
end;
write('Owner"s Surname: ');
write(p6);
end;
end;

begin
{$R-}
assign(f1, 'D:11-2dogs.pas');
rewrite(f1);
writeln('Type Number of Dogs');
readln(n);
input(f1,n);
reset(f1);
for i:=1 to n do
begin
new (a[i]);
read(f1,dub);
a[i]^:=dub;
end;
nh:=round(n/2);
for i:=1 to nh do
ah[i]:=a[i];
writeln(nh);
writeln('Type new elements count');
readln(nc);
writeln(nc);
for i:=(1) to (nc) do
begin
with ah[nh+i]^ do
begin
writeln('Type for new ',(i),' dog');
writeln('Type Club Number');
readln(p1);

writeln('Type breed: 0-Dog, 1-Pudel, 2-Bolonka, 3-Kolli, 4-Rotveiller');
readln(j);
p2:=breed(j);
writeln('Type Name');
readln(p3);
writeln('Type age');
readln(p4);
writeln('Type gender 0-f,1-m');
readln(j);
p5:=gender(j);
writeln('Type owner"s Surname');
readln(p6);
end;
end;

{1_s}
fl:=true;
while fl=true do
begin
fl:=false;
for i:=1 to n do
if (a[i]^.p4)>(a[i+1]^.p4) then
begin
dub:=a[i]^;
a[i]^:=a[i+1]^;
a[i+1]^:=dub;
fl:=true;
end;
end;
{2_s}
fl:=true;
while fl=true do
begin
fl:=false;
for i:=1 to (nh+nc) do
if (ah[i]^.p1)<(ah[i+1]^.p1) then
begin
dub:=ah[i]^;
ah[i]^:=ah[i+1]^;
ah[i+1]^:=dub;
fl:=true;
end;
end;

clrscr;
output(a,n);
writeln;
output(ah,(nc+nh));
writeln;

{$R+}
end.

вылетает с ошибкой 216 после 108 строчки

Код

writeln(nc);

Что делать?

    program sortirovki;

    {$s-}

    {$r-}

    type

         list=^zveno;

         zveno=record

         c:byte;

         next:list

         end;

         elem=record

         sgn:boolean;

         n:integer;

         zero:boolean;

         ch:list;

         kz:integer

         end;

         structure=array [1..1500] of elem;

    var

        B:structure;

        i,N,hs,M,l,prc,src,prh,srh,T:longint;

        c:char;

        p:list;

        vsgn:boolean;

    function compare(var x,y:elem):boolean;  {true, esli x>y}

    var px,py:list;

        fl:boolean;

    begin

    if x.sgn <> y.sgn then

     if x.sgn=false then compare:=true else compare:=false else

       if x.n<>y.n then

         if x.n < y.n then

           if x.sgn=false then compare:=false else compare:=true else

            if x.sgn=false then compare:=true else compare:=false else

           begin

             new(px);

             new(py);

             px:=x.ch;

             py:=y.ch;

             if x.ch^.c=0 then

             begin

               repeat

                 x.ch:=x.ch^.next;

               until x.ch^.c<>0;

             end;

             if y.ch^.c=0 then

             begin

               repeat

                 y.ch:=y.ch^.next;

               until y.ch^.c<>0;

             end;

             if x.ch^.c < y.ch^.c then fl:=false else fl:=true;

             while (x.ch^.c = y.ch^.c) and (x.ch<>nil) and (y.ch<>nil) do

             begin

               x.ch:=x.ch^.next;

               y.ch:=y.ch^.next;

               if x.ch^.c < y.ch^.c then fl:=false else fl:=true;

             end;

             x.ch:=px;

             y.ch:=py;

            if (x.sgn=false) and fl  then compare:=true else

             if (x.sgn=false) and not fl then compare:=false else

               if (x.sgn=true) and fl then compare:=false else compare:=true;

           end;

    srh:=srh+1;

    src:=src+1;

    end;

    procedure swap(var x,y:elem);

    var z:elem;

    begin

      new(z.ch);

      z.n:=x.n;

      z.kz:=x.kz;

      z.sgn:=x.sgn;

      z.zero:=x.zero;

      z.ch:=x.ch;

      x.n:=y.n;

      x.kz:=y.kz;

      x.sgn:=y.sgn;

      x.zero:=y.zero;

      x.ch:=y.ch;

      y.n:=z.n;

      y.kz:=z.kz;

      y.sgn:=z.sgn;

      y.zero:=z.zero;

      y.ch:=z.ch;

      prh:=prh+1;

      prc:=prc+1;

    end;

    procedure heapify(var B:structure;j:integer);

    var max:integer;

    begin

      if (2*j <= hs) and (not compare(B[j],B[2*j])) then max:=2*j else max:=j;

      if  (2*j+1 <= hs) and (not compare(B[max],B[2*j+1])) then max:=2*j+1;

      if j <> max then begin

        swap(B[j],B[max]);

        heapify(B,max);

      end

    end;

    procedure heapsort(var B:structure);

    var i,l:integer;

    begin

      for i:=hs div 2 downto 1 do

        heapify(B,i);

        {for l:=1 to N do

         write(a[l],’ ‘);}

      for i:=hs downto 2 do

      begin

        swap(B[1],B[i]);

        dec(hs);

        heapify(B,1);

      end;

    end;

    procedure chsort(var B:structure);

    var i,j:integer;

    begin

      i:=1;

      while i<N do

      begin

        if compare(B[i],B[i+1]) then

          begin

           j:=i;

           while (not compare(B[j+1],B[j])) and (j <> 0) do

           begin

             swap(B[j],B[j+1]);

             dec(j);

           end;

           inc(i);

          end else inc(i);

      end;

    end;

    function vvod(var B:structure):string;

    var s:char;

        fl:boolean;

        i:integer;

        p:list;

        cp:boolean;

    begin

      i:=0;

      repeat

        inc(i);

        fl:=true;

        read(s);

        if (s<>’ ‘) and (s<>’.’) then

        begin

          if s=’-‘ then begin read(s);B[i].sgn:=true; end else B[i].sgn:=false;

          if (s=’0′) and fl then B[i].kz:=B[i].kz+1 else

          begin

            B[i].n:=B[i].n+1;

            fl:=false

          end;

          if s<>’0′ then B[i].zero:=false else B[i].zero:=true;

            new(B[i].ch);

            B[i].ch^.c:=ord(s)-ord(‘0’);

            B[i].ch^.next:=nil;

            new(p);

            p:=B[i].ch;

          repeat

            read(s);

            if (s<>’ ‘) and (s<>’.’) then

            begin

              if s=’0′ then B[i].zero:=B[i].zero and true else B[i].zero:=false;

              if (s=’0′) and fl then B[i].kz:=B[i].kz+1

              else

              begin

                B[i].n:=B[i].n+1;

                fl:=false

              end;

              new(B[i].ch^.next);

              B[i].ch:=B[i].ch^.next;

              B[i].ch^.c:=ord(s)-ord(‘0’);

              B[i].ch^.next:=nil

            end;

          until (s=’ ‘) or (s=’.’);

          B[i].ch:=p;

          T:=T+1;

        end;

      until (s=’.’);

    vvod:=»;

    end;

    begin

    T:=0;

    assign(input,’input.txt’);

    assign(output,’output.txt’);

    reset(input);

    rewrite(output);

    src:=0;

    prc:=0;

    srh:=0;

    prh:=0;{

      writeln(‘Vvedite razmer massiva’);

      read(N);

      writeln(‘Vvedite elementi massiva’);

      for i:=1 to N do

      begin

        read(x[i]);

        y[i]:=x[i];

      end;

        chsort(x);

        writeln;}

         {

      writeln(‘Kolichestvo sravnenii i prisvaivanii dlya chelnok ‘,src,’ ‘,prc);

      writeln(‘Kolichestvo sravnenii i prisvaivanii dlya heapsort ‘,srh,’ ‘,prh);

      writeln(‘Rezultati sortirovki: 1)chelnok for X, 2)heapsort for Y’);

      for i:=1 to N do

        write(x[i],’ ‘);

        writeln;

      for i:=1 to N do

        write(y[i],’ ‘); }

      {probi vivoda}

      vvod(B);

      hs:=T;

      N:=T;

      heapsort(B);

      {chsort(B);}

      {writeln(prh,’ ‘,srh);}

      {writeln(B[1].ch^.c);}

      {writeln(compare(B[1],B[2]));}

      {writeln(B[1].n,’ ‘,B[2].n);}

      {writeln(B[1].ch^.next^.next^.c);}

      {writeln(compare(B[1],B[3]));}

      {writeln(T);}

      for i:=1 to T do

      begin

        new(p);

        p:=B[i].ch;

        vsgn:=true;

        while (B[i].ch<>nil) do

        begin

          if (B[i].sgn=true) and vsgn then begin vsgn:=false; write(‘-‘) end;

          write(B[i].ch^.c);

          B[i].ch:=B[i].ch^.next;

        end;

        write(‘ ‘);

        B[i].ch:=p;

      end;

      {end probi}

    readln;

    readln;

    close(input);

    close(output);

    end.

Понравилась статья? Поделить с друзьями:
  • Ошибка 2192 хендай солярис
  • Ошибка 226 ростелеком
  • Ошибка 216 0xd8 при запуске службы
  • Ошибка 2192 солярис что делать
  • Ошибка 226 роблокс