Beruflich Dokumente
Kultur Dokumente
Psacal
Psacal .
,
.
, ,
,
.
, .
() ,
.
, .
. ,
.
, (
). ,
. ,
- .
Psacal ,
.
,
.
1 Psacal
,
() () ,
. Psacal
:
-
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
- +, -, *, /, #, $, %, ^, &, (, ), _, [, ], {, }, \, |, , , .,
Psacal ,
.
. Psacal :
() Pascal
and
do
function
interface
packed
set
until
alfa
maxint
array
downto
goto
label
procedure
*string
*uses
boolean
nil
begin
else
if
mod
program
then
var
char
output
case
end
implementation
not
record
to
while
false
real
const
file
in
of
repeat
type
with
input
text
div
for
inline
or
set
*unit
*xor
integer
true
Psacal ,
. ,
, .
, end, End END Psacal.
, (, ++, Java), .
.
2 Pascal
Psacal ,
, ( )
. : ,
. . 5.1
Psacal, .
program First ;
Var im, jm : integer ;
X, y : real ;
begin
im:=5 ; jm:=9 ; y:=2.5 ;
X:=y*im/jm ;
writeln (Hello, this is my first program, X) ;
end.
. 5.1 Psacal
,
. ,
,
. ,
. program,
.
, Psacal.
, First. , ,
First,
, .
() ,
.
,
. , var,
(
). im jm
x y . -
.
. begin end ..
,
, .
im, jm y, x .
Hello, this is my first program x.
,
.
().
,
.
,
.
3. .
. ,
{ }
program First ; { }
(* *)
.
Var im, jm : integer ; { }
,
X, y : real ; { }
,
{ ;
begin
end}
.
begin
im:=5 ; jm:=9 ; y:=2.5 ;
X:=y*im/jm ;
,
writeln (Hello, this is my first program, X) ;
end.
.
.
,
.
.
, ,
.
Pascal {,
}. Pascal,
(* *),
.
. .
- :
4. ()
-, Psacal ,
( ),
. ,
,
.
.
. Psacal :
.
. , 3.14159 ( p), 100 (), ,
. ,
, ,
. () ,
.
( p=3.14159):
S := 3.14159 * d * d / 4;
. Psacal
(), ,
, . ,
(),
. , ,
, , ,
... , ,
ASCII ,
.
, , ,
, . ,
const:
const pi = 3.14159 ; const gravity = 9.81 ;
, pi gravity ,
.
, .
-
. ,
.
, .
, , ,
,
, .
, .
, , ..
, , ,
.
,
.
, .
() .
,
. ,
, .
, 8 .
, , 8 ,
.
: _ ( ), ....
,
. ,
Dimension, Velocity
.. ,
().
. ,
, .
, (
) .
.
, .
, ,
.
Psacal var (variable
).
.
( ) .
()
,
, . Psacal,
.
.
Pascal, integer,
. :
Var ii : integer ;
j : integer ;
:.
,
, :
Var j, i, m, n : integer ;
ix, jx : integer ;
(16 ),
- 216=64536.
,
integer -32768 32767.
, Pascal
. :
T
Integer
LongInt
Byte
Word
-32768.. 32767
2147483648..2147483647
0 .. 255
0 .. 65535
Format (. )
()
2
4
1
2
.
:
+ ; (+); - ; (-); (*);
(/), (
). ,
( ).
:
- div ( ).
a div b - a b .
- mod ( )
a mod b - .
:
15 div 5 = 3 ;
15 mod 5 = 0 ;
15 div 4 = 3 ;
17 mod 5 = 2 ;
:
abs (a) - ;
sqr (a) - 2 ;
succ (a) - - ;
pred (a) - -.
Pascal :
- ;
- ;
- .
:
354.12;
-0.1412;
15.0;
57 -4;
42 5 ;
-25 -2;
28.42 +2; -8.546-2;
,
. , 8.24 -2 :
8.24 -2 = 8.24 10-2 = 0.0824
:
.001 ; 6,24 ; -4 ;
const:
const One = 1.0 ;
e = 2.71 ;
eps = 0.0001 ;
Pascal.
real.
Var x, u : real ;
y, xy, temperature : real ;
:
+ ; (+); - ; (-); (*); (/).
.
:
abs (x) - ;
sqr (x) - x2 ;
sqrt (x) - ;
sin (x) - ;
cos (x) - ;
ln (x) - .
:
trunc (x) - ,
;
round (x) - :
trunc ( x + 0.5) x 0;
round (x) =
trunc ( x 0.5) x 0
:
trunk (28.15) = 28 ;
trunk (-12.3) = -12 ;
round (13.56) = 14 ;
round (-12.4) = -12.
frac (x) - :
frac (17.12) = 0.12 ;
Format (. )
5.0 x 10^324 .. 1.7 x 10^308
1516
5.0 x 10^324 .. 1.7 x 10^308
1516
3.6 x 10^4951 .. 1.1 x 10^4932
1920
()
8
8
10
- Pascal, (real) 4 ,
double - 8 , .
BOOLEAN. ()
True ( ) False ().
,
:
const pi=3.14159 ;
e=2.71 ;
Var bool1, bool2 : Boolean ;
.
bool1:=true ;
bool2:=pi>e ;
, bool1 true, bool2 (pi>e).
( )
. Pascal :
=
- ;
>
- - ;
<
- -
>=
- -
<=
- -
<>
- .
,
. - and
( ), or ( ) not ( ):
Var a, ix, j: integer;
IsFound, Error, Ok : Boolean ;
.
IsFound := a = ix ;
Error := (a<0) and (a>9) ;
Ok := not Error and (IsFound or (a<>5));
, false<true:
true = false - false;
true>false
- true;
false>true
- false.
.
- odd(N) - ,
N:
true ako N
odd (N) =
false ako N
- KeyPressed ( Crt) -
.
true ako
KeyPressed =
false ako
( ).
Pascal
.
,
. ASCII
(- ). 48 57,
65 90 - 97 122.
Pascal.
: , Q, 3, %, +, w.
#: #65, #48, #97, ... , 1, .
().
const Character = A;
blank = ;
CR = #13 ; Plus = + ;
()
() #39. 1 .
ASCII 256 ( 0 255).
() :
Var
Ch : Char ;
Symb, Letter : char ;
( ).
0 255.
:
- ord - . :
ord(0)=48 ; ord(A) = 65.
- char - .
: char (48) = 0 ; char (90) = Z; char (ord (c)) = c.
- pred succ
. : succ(0) = 1; pred(W) = V;
succ(predd(f))=f.
.
a b a>b, a
- b, . ord (a) >ord(b) .
:
> B e false ;
9>A e false;
p>p e false;
p>A e true.