a) b)
2 - , .
b1=false b2=0.
- : , .
. , , , cand (conditional and, ). and . . {$B}
: n
1
i:=1; while (i≤n) and (a[i]=x) do i:=i+1;
1. i:=1; read(a); while (i≤n) and (a=x) do begin
read(a);
i:=i+1;
end;
2. i≤n) and (a[i]=x)
: , . , true or 0.
:
not(not_b)=b
not(b1and b2)=not b1or not b2
not(b1or b2)=not b1and not b2
: , .
: .
Program poisk4(input,output);
Var a,x:integer;
found:boolean;
begin
found:=false;
read(x);
while not eof() and not found do
begin
read(a);
if x=a then found:=true;
end;
end.
.
: , .
b:= ( 1) or ( 2) or ( )
1:= (y>=x+1) and (sqr(x)+sqr(y)<=1)
2:= (y>-x-1) and (sqr(x)+sqr(y)<=1).
:= (abs(y)<=x) and (x<=1).
: . .
.
X:
X={x1, x2, x3, }
"x ÎX B(x)=B(x1) and B(x2) and B(x3)
$x ÎX B(x)=B(x1) or B(x2) or B(x3)
{b="xÎX B(x)}
b0:=true
bi+1:=bi and b(xi+1)
|
|
b:=true
i:=1
while (i<=n) and b do begin
if not B(xi+1) then b:=false;
i:=i+1;
end;
,
Begin
assign(f,input.txt);
reset(f);
b:=true;
if eof(f)=false then
begin
read(f,ao);
while(eof(f)=false) and b do
begin
read(f,a);
if ao<=a then ao:=a
else b:=false;
end;
end;
writeln(b);
close(f);
End.
.
b:= $ iÎ[1..n] (x=ai
: , . , .. , c1<2, c1 , 2. succ(c), pred(c).
, , :
a<b<c<
A<B<C<
a a
0<1<2<
, chr ord.
chr(i) i
ord(a)
, - .
: .
:
1.
2. :
:
1. (0,1,,9). 1.
2. .
2,0,0,1
2001
2103+0102+0101+1100
.
m=1 ord(c)-ord(0)
m=2 n=
n+1=ni10+ci
.
, .
1. nÎ[0,9] chr(n+ord(0))
2. n=
ci+1=ni mod 10
ni+1=ni div 10
: c n , n 0.
: .
3: .
()
A:array[I] of T, ( , ). I .
:
:
1. : I [1..n], [0..n]. n. - ; f: NT, .. [1,n] T
2. . f: IT. I , I T . , ().
, A[e] A , e I (a[e]=app(a,e) ). , .
, () .
( ) , .. -.
|
|
. y:=a[x]. y a(x).
.
( ) .
. a[x]:=y. a[x] y.
, . .
. n.
( ).
array[I1] of array [I2] of T a [x][y] array[I1,I2] of T a[i,j]
array[I1,,In] of T a[i1,,in];
n.
: .
: [a, , s], N ( ).
{ki i- }
assign(f,);
reset(f);
for c:=a to z do k[c]:=0;
while not eof(f) do
begin
read(f,c);
k[c]:=k[c]+1;
end;
close(f);
. , (, ). .
. .
array of T.
: nÎN.
.
a: array of T . , , a[1]:=1; .
, .. setlength(a,b); a ; b , , . length(). .
, . ( ) . .
: , .
1. .
2. , , , .
Object Pascal Delphi, .
String 255 . , , :
1. ()
S:=S1+S2, S1=c1,,cn, S2= c1¢cm¢, S=c1,,cn,c1¢cm¢
2. . () : S1<S2, S1=c1cn, S2=c1¢cm¢. i , ci<ci¢. i , . S1<S2, ci<ci¢ char.
<
<
, .
string , succ pred .
|
|
: J
Record
N1: T1;
..
Nm: Tm;
End.
, N1,,Nm. f(N1)ÎTi "i=1,,m
.
m, , tiÎTi.
Real2=RealReal
{<t1,t2>, t1Îreal, t2Îreal}
N1,,Nm, T1,,Tm, . , , , .
r.Ni, r , Ni N1,,Nm.
, .
type
tTochka = record
x,y: real;
end;
{x,y }
record
ugol,radius: real;
end;
{ }
Begin
read(n,x,a);
s:=a; k:=1;
for i:=1 to n do
begin
read(a);
k:=xk;
s:=s+ak;
end;
write(s);
End.
: .
Type complex=record
re:real;
comp:real;
end;
Var i,n: integer;
l:real;
x,a,k,s: complex;
Begin
read(n,x.re,x.comp,a.re,a.comp);
s.re:=a.re;
s.comp:=a.comp;
k.re:=1;
k.comp:=0;
for i:=1 to n do
begin
read(a.re,a.comp);
l:=k.re;
k.re:=x.rek.re-x.compk.comp;
k.comp:=x.rek.comp+lx.comp;
s.re:=s.re+a.rek.re-a.compk.comp;
s.comp:=s.comp+a.rek.comp+a.rex.comp;
end;
if s.comp<0
then
write(s.re,-,abs(s.comp))
else
write(s.re,+,abs(s.comp));
End.
: . :
1.
2.
3.
4. /
5.
, 5 , (, ).
: with r do s, r , s , r.Ni Ni.
: S, Ni r.Ni.
.
file of T, , .
: , .
: Assign (AssignFile), reset, rewrite, eof, close (CloseFile) . read write , .
Read(f,v), f , v .
Write(f,e), f , .
readln, writeln, eoln .
, .
i Î [1,len(a)] (ai<=ai+1)
i,j Î [1,len(a)] (i<=j → ai<=aj)
, .
|
|
Found:=
ai=x
$ iÎ[1,len(a)] (ai>=x)
: i, x<=ai, found:=true Û x=ai, ; , found:=false.
, i: ai>=x
found1:=$i (ai>=x)
assign(f,);
reset(f);
found1:=false;
while (not found1) and (not eof(f)) do
begin
read(f,a);
if a>=x then found1:=true
end;
if found1 then found:=a=x
else found:=false;
: , , . - .
: , ( ). . .
:
f3=f1\f2
reset(f1);
reset(f2);
rewrite(f3);
while
begin
read(f1,x);
If {xÏf2} then write(f3,x);
end
, , f1 , f2 bi>=ai ai, bj¢>=bj.
Program Binar;
Var a:array[1..n] of integer;
l,r,m:integer;
found:boolean;
Begin
{ a}
l:=1;
r:=n;
found:=false;
while (l<=r) and not found do
begin
m:=(l+r) div 2;
if a[m]=x
then found:=true
else if a[m]<x then l:=m+1
else r:=m-1;
end;
end.
{ , , , .. }
"i (ai<=ai+1)
"i,j (i<=j → ai<=ai+1)
:=(,)
a1<=<=an x
Begin
{ a}
for k:=2 to n do
begin
x:=a[k];
j:=k-1;
while (j>0) and (x<a[j]) do
begin
a[j+1]:=a[j];
dec(j);
end;
a[j+1]:=x;
end;
End.
{ , , }
0 1 , . i- ai ; n-1 .
j, aj<ai, , ai aj+1, .. j+1 , ai.
: set of T, .
:
set of T a1, ,an . . , a1, , an .
[E1, , En], Ei , i1 Ej2, i1 Ej2 , [2,2,1,,7].
1. .
X in S ~ XÎS
S1<=S2~ S1 S2
2. - .
S1+S2~ S1ÈS2
S1*S2 ~ S1ÇS2
S1-S2 ~ S1\ S2
3. - .
( ).
Fs(x)=true(~)xÎS
- , .
x Î S ~ Fs(x) =true
S1 S2 ~ " x Î S1 (x Î S2)
x Î S1 È S2 ~ fs1(x) or fs2(x)
x Î S1 Ç S2 ~ fs1(x) and fs2(x)
x Î S1\ S2 ~ fs1(x) and not fs2(x)
.
((x>=1)and(x<=10)) or ((x>=20)and(x<=40))
x:n[1..10]+[20..40]
n.
Program Eratos(input,output);
Type tNumbers=0,255;
Var n:integer;
Primes: set of tNumbers;
Numbers: set of tNumbers;
Begin
Read(n);
Numbers:=[2,n]
Primes:=[ ];
While Numbers<>[] do
Begin
{ Numbers}
While not (p in numbers) do p:=p+1;
{ Primes }
Primes:=Primes+[p]
{ Numbers}
K:=p;
While k<=n do
begin
Numbers:=numbers - [k];
K:=k+p;
end;
|
|
end;
{ Primes}
For k:=1 to n do if k in Primes then write(k);
end.
.
: Y:=(A+b)*C+D*(A-D)/(C-D), A,B,C,D Î Q
Type tRational;
Var A,B,C,D: tRational;
Y: tRational
Z,T: tRational;
Chis,znam:integer;
Begin
{read(a,b,c,d)}
{y:=a+b};{z:=a-b};{t:=c-d};{z:=z/t}
{z:=d+z}{y:=y+z}
{write(y)}
end;
(, , ) ,
→
Procedure → ( ).
→ (, ).
() , . : v:t var v:t, t , v .
V ( ), . , , .
← →
, , ; .
.
()
, , . . , .
() . .
.
( ).
, , 1,,n.
, , . , .
.
.
, .
: ( , ) ( , ).
X:=x+y;
( ). .
, var-, , .
, .
. .
Type tIndex=1..100;
tVector=array [tIndex] of real;
procedure max;
a: tVector;
n: tIndex;
Var m:real;
Begin
M:=a[i];
For i:=2 to n do
If m>a[i] then m:=a[i];
End.
: , , .
?
Max(b,10,x);
(, ), ( ) .
, , , , , .
:
1) . , .
M:=a[i];
For i:=1 to n do
If m>a[i] then m:=a[i];
2)
3) .
()
, , ( ). , , . (.. ), () . , , , . : ( ).
Procedure Max;
Var a: tVector; n: tIndex;
Var m: real;
max(b,10,x);
x:=b[1];
for I:=1 to n do
if x>b[I] then m:=b[I];
x:=a[1];
for I:=1 to n do
if x>a[I] then m:=b[I];
{max[10,x]}
, , . .
( ):
. , , .
().
Procedure Sort(var a: tVector; var b: tVector);
Var i,k,l: tIndex;
Begin
K:=1; l:=na;
For I:=` to na do
If a[I]>0 then
L[k]:= a[I]
Else begin
B[l]:= a[I];
K:=k+1;
End;
End.
sort(c,c)? (c:tVector), . , . .
: . ?
. , .
: ( ).
: .
.
() (). 1 . .
Function ( ) ( ).
( ) ( )
.
, , , ( := ).
. . Delphi :
Result:= , result .
Function max(var a: tVector; n: tIndex): tComponent;
Begin
M:=a[1];
For I:=2 to n do
If m<a[i] then m:=a[i]; max:=m;
End.
: : .
: . .
:
V:= , V , .
, .