Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Random Numbers
//fpc 3.0.0 program HelloWorld; type list = ^node; node = record data : Integer; next : list; end; procedure addBack(var l : list; i : Integer); var aux, pos : list; begin New(aux); aux^.data := i; aux^.next := nil; if l = nil then l := aux else begin pos := l; while pos^.next <> nil do pos := pos^.next; pos^.next := aux; end; end; procedure addOrdered(var l : list; i : Integer); var aux, current, last : list; begin New(aux); aux^.data := i; aux^.next := nil; current := l; last := l; while (current <> nil) and (i > current^.data) do begin last := current; current := current^.next; end; if last = current then l := aux else last^.next := aux; aux^.next := current; end; procedure writeList(l : list); begin while l <> nil do begin Write(l^.data); Write(' | '); l := l^.next; end; end; var l : list; i : Integer; begin Randomize(); l := nil; for i := 1 to 500 do addOrdered(l, random(900) + 100); writeList(l); end.
run
|
edit
|
history
|
help
0
Menukar nilai1
eje8
janja - naloga 1 - 11.7.2013
9
Linija
Complemento da VS ICC II - 1º Semestre 2017
1
Sss
звёздное небо и подсчёт кратных звёзд
zad27-optimized