Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
test28
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
program test28; {pointer example of direct chain growth and key inf change} type spisok=^elem; elem=record inf:real ; sled:spisok end ; label 1,2; const M:integer = 5; var a, pervy,d,l: spisok ; mas: array[1..5] of integer ; i,r:integer ; b:boolean; procedure sostavlenie2(var p1:spisok; N:integer) ; var q,p2:spisok ; begin New(q) ; {data generator} p1:=q; {head safe} p2:=q; for i :=1 to N do begin q^.inf:=mas[i] ; q^.sled:=Nil; p2^.sled:=q; p2:=p2^.sled; New(q); end ; end ; begin M:=5; for i:=1 to M do mas[i]:=i ; sostavlenie2(pervy, M) ; a:=pervy ; l:=a; r:=0; b:=true; New(d); {make new element} d^.inf:=10; d^.sled:=Nil; while (a<> nil) and b do if a^.inf=3 then {appoint the element} begin b:=false; {key inf achieved} if r>1 then for i:=1 to r-1 do l:= l^.sled; l^.sled:=d; d^.sled:=a^.sled; {change appointed element with new element "d"} end else begin a:=a^.sled; if a=Nil then goto 1 ; r:=r+1; end; begin writeln('Appointed element is ',a^.inf:2:1) ; {show appointed element} writeln; a:=pervy; repeat writeln(a^.inf:2:1) ; a:=a^.sled; until a=Nil; goto 2 ; end; 1: writeln('no such key info element'); 2:end.
Show compiler warnings
[
+
]
Show input
Compilation time: 0.12 sec, absolute running time: 0.16 sec, cpu time: 0.01 sec, memory peak: 5 Mb, absolute service time: 0,44 sec
edit mode
|
history
|
discussion