: , Pascal C++, .
:
1.
2.
3. IDE ( )
4.
. .
: , . .
:
1. , , .
2.
3. , , .
4.
5. IDE (-)
6. -
7.
2. .
3. IDE.
:
^ - ctrl
# - shift
@ -alt
4. .
.
1.
2. , , .
3. - .
4. (?)
5. .
5. .
1. (, , )
2. ( , , )
: , ,
3.
, , ,
4. , . (, )
( ), ( )
5. ( )
6. ()
7.
8. ,
9.
7-9 IDE
10. ( )
: , , , , , .
.
6. . , .
, , .
:
1)
2) ()
3) ( )
4)
|
|
5)
(?) , .
. .
-
-
-
- ()
.
1.
2.
3.
. . .
( case <> of)
7. .
, .
1.
() , .
, .
2. ( )
:
Program TestA2;
Var A:array[1..10] of real
S:Real;
i:{1..11}Byte;
Povtor: Boolean;
Begin
{ }
S:=0;i:=1;
Povtor:=True;
While Povtor do
If A[i]<0 then Povtor:=FALSE
Else
Begin
S:=S+A[i];
i:=i+1;
if I>10 then Povtor:=FALSE;
end;
writeln(S)
end.
3. ( )
1.
2. (- Sost:=1)
3. Si-> Si+Sost:=next N2
4.
5.
-.
While sost<>o do
Case sost of
1:..
2:
End;
, ,
:
While sost<>0 do
Case sost of
1: if p1 then sost:=3 else sost:=2;
2: begin s1; sost:=4; end;
3:if p2 then sost:=5 else sost:=4;
4:if p3 then sost:=0 else sost:=2;
5:begin s2;sost:=0; end;
End;
8. .
1)
:
Sum:=0;
For i:=1 to N do
Sum:sum+A[i];
:
P:=1;
For i:=1 to N do P:=P*A[i];
, .
, , .
Fact:=1;
Readln(N);
For i:=1 to N do
Fact:=Fact*I;
Writeln(Fact);
2) .
!:
)
) ,
)
) ():
Example.
Program qq; uses crt;
Var n:Integer;
A,S,x,Eps:Real;
Begin
Clrscr;
Writeln( x,Eps);Readln(x,Eps);
S:=0;A:=1;n:=0;
Repeat
S:=S+A;
N:=n+2;
A:=A*(-x*x)/(n*(n-1));
Until ABS(-x*x/n*(n*(n-1))<Eps; {a/s<Eps}
Writeln(S);
End.
3) ()
4) ,
9.
|
|
.
:
1)
2)
3) .
, :
1.
While < > do <>
2.
:
Repeat
<>
Until < >
while . , , while,
3. .
P=H,K, |
:
For i:=< > to < > do <>
10. . .
N=(S) |
Chislo=0 |
I=1,s,1 |
Chislo=chislo*10+(ord(s[i])-ord(0)) |
11. : .
12.
: A..Z(a..z) A≡a, 0..9, +,-,;,
: begin, end,
:
{..} (*..*)
(), +/. , 63 .
:
1) ()
2) ()
3) ( )
. 16.
13. . . .
, . .
:
1.
. , , ( )
2. ()
( ), , .
( *.exe)
1) (.ASM->.exe)
2) (asm->exe)
3) (.pas->.exe)
4)
.exe. ( ).
. - ( )
14.
:
1.
2.
3. ,
4.
( )
1.
2.
3.
4.
:
1):
a)
(ShortInt(1byte),Integer(2byte),LongInt(4b),Byte(1b),word(2b))
(char(1b))
(Boolean)
(one, two, three), 1..10, d..f
b)
Real(6b),
Single(4b),Double(8b), Extended (10b), comp(8b) {$N+}
2)
a) ( ) ^|Pointer -1byte
b) (string)(255 )
c) () array
d) ( record)
e) (set of)
f) file text
g) (object)
Boolean
: ½
: True/False
: : NOT,OR,AND,XOR
>,<,<=,<>,>=,,=
:
Function odd(N:):Boolean
True, N , else FALSE
Function Eoln (var text):Boolean;
If then true else false
|
|
1) ShortInt -1byte (-128..+127)
2)Integer 2byte
3) LongInt
MaxInt,MaxLongInt (, Integer LongInt)
4)byte 1byte (0.255)
5) word 2byte (0..65)
3) +,-,*,div, mod (-: 20 div 7 ->2)
- >,<,>=,<=,<>,=:Boolean
SHL (<-), SHR(->)
-: N SHL 2 = N*2^2
: NOT,OR,AND,XOR ,
4) ABS(n)- n
SQR(n)- n^2
Round(x:)-
Trunc(:)
Real(6byte)
( {$N+})
Single 4b
Double 8b
Extended 10b
Comp 8b
Real +-y.<10 >E+-pp
+-y.<14 >E+-pppp
3) +,-,*,/
- >,<,>=,<=,<>,=:Boolean
4)
ABS(x),SQR(x),SQRT(x)
sin(x), cos(x), pi, arctg(x), ln(x), exp(x)=e^x
Int(x)
Frac(x)-
(char)
: 0..255
( )
: ord(ch:char):byte ch
Chr(:byte):char
Chr(0)..chr(255)- char
, . , , :
type
colors = (red, white, blue);
, .
:
a: min..max;
a , min , max (). .
()
:
:array[ Index] of < >
Index , LONGINT
, ,
()
: , .
Type Tdate=record
Day:1..31;
Month:1..12;
Year:Integer;
Var Date:array[1..N] of TDate
. , , , - . , , .
type Effect=Record
Nomer: Integer;
Case Proverka: Boolean of
FALSE: (PrinimalRanee: Boolean);
TRUE: (GolovBol,Lihoradka,Toshnota: Boolean)
end;
var Nekto: Effect;
. .
, .
:
;
;
;
.
, ord() 0 255.
|
|
Type <_>= set of <_>
(+), (-) (*).
. TP 3 :
1.file
2.file of < >( )
3.text ( , )
1. var F:file of < >
2. assign(f:file;filename:string)
3.
Reset(var f:file)-
Rewrite(var f:file)
{$I+}
IORESULT -.
.
read(f:file,< >)
write(f,exp:< >)
EOF(F)-boolean
:
CLOSE(f).
. close .
.
: EOLN(var F:text)
read, write
writeln readln .
128 .
: settextbuf( , ). assign, reset. .
.
string. . 255 . , . , , .
15. .
[<>]
< >
begin
< >
End.
:
< > - label
< > const
< > type
< > var
< > procedure/function
, .
.
.
, ( 0 9999).
.. . . . . .. .
LABEL LB1, LB2, R8;
.
Const <>=<>;
Const =ord(9)-ord(0)+1;
.
Const <>:=.
Found:Boolean=true;
Const NEWYEAR:record
D:Byte;
M:Byte;
Y:Integer;
End=
(1,1,2012)
.
Type <>=<>
.
Var <>:;
Var : absolute < >
Absolute .
, - . , .
, . , .
16. .
:
() :
1)
2) (+,-,@,NOT)
3) (*,div,/,mod,AND,shl,shr)
4) (+,-,OR,XOR)
5)
17. .
. , , .
, . .
GOTO ( )
, .
, . , GOTO, LABEL .
|
|
:
Program Test;
Label lb1;
Var b:real;
Begin
Goto lb1;
For i:=1 to 4 do
Writeln(b);
Lb1:readln(b);
End.
.:=
, , .
C (BEGIN END;).
, . , , BEGIN END
IF
CASE
. CASE () , , . . , CASE
, CASE , . ELSE , , , , . , ( , ) .
WHILE ( ).
, . 0 .
While <> do <>
REPEAT UNTIL( ).
, . , REPEAT UNTIL, , . TRUE- , FALSE, .
Repeat
<>
Until <false>
, , .
FOR DO
( ), , .. ,
, . , READ READLN, .
. , , DOWNTO .
18. .
, , .
,
. .
for
program chars;
procedure kodtable;
const n=255;
var i:byte;
ch:char;
begin
for i:=1 to n do begin
ch:=chr(i);
writeln(ch:3,i:4);
inc(i);
end;
end;
begin
kodtable;
readln
end.
while
program chars;
procedure kodtable;
const n=255;
var i:byte;
ch:char;
begin
i:=0;
while i<=255
ch:=chr(i);
writeln(ch:3,i:4);
inc(i);
end;
end;
begin
kodtable;
readln
end.
until
program chars;
procedure kodtable;
const n=255;
var i:byte;
ch:char;
begin
i:=1
repeat
ch:=chr(i);
writeln(ch:3,i:4);
inc(i);
until i>255;
end;
begin
kodtable;
readln
end.
: .
. -
{ }
procedure qwer;
var i,j:Integer;
begin
writeln(' ');
for i:=1 to N do begin
for j:=1 to N do
read(matrix[i,j]);
readln;
end;
{ }
procedure vyvod;
begin
write('|':7);
for j:=1 to n do write(j:6);
writeln;
for j:=1 to n*8 do write('-');
writeln;
for i:=1 to N do begin
writeln('|':7);
write(i:6,'|');
for j:=1 to N do
write(round(matrix[i,j]):6);
writeln;
end;
end;
. 1010
program matrixXmatrix;
var a:array[1..10,1..10] of Integer;
i,j,minx,miny,min,n1,n2:Integer;
procedure poisk(n1,n2:Integer);
var i,j:Integer;
begin
min:=a[1,1];
minx:=1;miny:=1;
for i:=1 to n1 do
for j:=1 to n2 do begin
if a[i,j]<min then begin min:=a[i,j];minx:=j;miny:=i;end;
end;
end;
begin
writeln(' );
readln(n1,n2);
writeln(' ');
for i:=1 to n1 do begin
for j:=1 to n2 do
read(a[i,j]);
readln;
end;
poisk(n1,n2);
writeln( :,minx:3,miny:3);
readln
end.
19. .
: .
program tableStudentsofMyGroup;uses crt;
type
Person=record
Family:string;
mark:array[1..6] of Byte;
end;
var T1:text;
Student:array[1..20] of Person;
i,j,n:Integer;
begin
clrscr;
assign(t1,paramstr(1));rewrite(t1);
writeln(' ');
repeat
writeln(' ');
readln(n);
if (n>20) or (n<1) then writeln(' ');
until (n>=1) and (n<=20);
{ }
for i:=1 to n do
with Student[i] do begin
write(' : '); readln(family);
write(' : ');
for j:=1 to 6 do
read(mark[j]);
readln;
end;
for i:=1 to n do
with Student[i] do begin
write(t1,family:20);
for j:=1 to 6 do
write(t1,mark[j]:3);
writeln;
end;
readln
end.
:
program tableStudentsofMyGroup;uses crt;
const n=30;
type
Person=record
Family:string;
mark:array[1..6] of Byte;
end;
var T1:text;
Student:array[1..20] of Person;
i,j,n:Integer;
begin
clrscr;
writeln(' ');
assign(t1,paramstr(1));reset(t1);
until (n>=1) and (n<=20);
{ }
n:=0;
while not eof(t1) do
with Student[i] do begin
read(t1,family);
for j:=1 to 6 do
read(t1,mark[j]);
readln;
end;
n:=n+1;
for i:=1 to n do
with Student[i] do begin
write(family:20);
for j:=1 to 6 do
write(mark[j]:3);
writeln;
end;
readln
end.
: .
IORESULT. -. , 0.
20. .
: . .
, , TP 255 .
.
program copytext1;
var T1,T2:text;
ch:char;
begin
assign(T1,paramstr(1));reset(T1);
assign(T2,paramstr(2));rewrite(T2);
while not Eof(T1) do begin
while not eoln(T1) do begin
read(T1,ch);write(T2,ch);
end;
readln(T1);writeln(T2);
end;
end.
.
program copytext1;
var T1,T2:text;
s:string;
begin
assign(T1,paramstr(1));reset(T1);
assign(T2,paramstr(2));rewrite(T2);
while not Eof(T1) do begin
readln(T1,s);writeln(T2,s);
end;
end.
.
program delpr1;
var T1,T2:text;
ch:char;
bool:boolean;
s:string;
begin
assign(T1,paramstr(1));reset(T1);
assign(T2,paramstr(2));rewrite(T2);
while not Eof(T1) do begin
bool:=true;
while not eoln(t1) do begin
while bool do begin
read(t1,ch);
if ch:=' ' then write(t2,ch) else bool:=false;
end;
write(t2,ch);
while ch<>' ' do
read(t1,ch);write(t2,ch);
write(t2,ch);
while ch=' ' do read(t1,ch);
end;
readln(t1);
writeln(t2);
end;
end.
.
program delpr2;
var T1,T2:text;
ch:char;
Sost:1..3;
begin
assign(T1,paramstr(1));reset(T1);
assign(T2,paramstr(2));rewrite(T2);
while not Eof(T1) do begin
sost:=1;
while not eoln(T1) do
case sost of
1:begin
read(t1,ch);
if ch<>' ' then sost:=2;
write(t2,ch);
end;
2:begin
read(t1,ch);
if ch=' ' then sost:=3;
write(t2,ch)
end;
3:begin
read(t1,ch);
if ch<>' ' then begin sost:=2;write(t2,ch);end;
end;
end;
readln(T1);writeln(T2);
end;
end.
21. -.
- input, output.
, read(<>);
INPUT () OUTPUT () .
.
Program max;uses crt;
Var max,n,I,k:Integer;
Begin
Writeln( );
Readln(n);
Writeln( );
Read(k);
Max:=k;
For i:=2 to n do begin
Read(k);
If max<k then max:=k;
End;
Writeln( - ,max);
readln
End.
22. -. .
---------T-------------------------------------------
+------------------+--------------------------------------------+
Append -
.
+------------------+--------------------------------------------+
Assign -
.
+------------------+--------------------------------------------+
BlockRead
.
+------------------+--------------------------------------------+
BlockWrite
.
+------------------+--------------------------------------------+
ChDir .
+------------------+--------------------------------------------+
Close .
+------------------+--------------------------------------------+
Erase .
+------------------+--------------------------------------------+
Ef end-of-file
( ).
+------------------+--------------------------------------------+
FilePos .
.
+------------------+--------------------------------------------+
FileSize . -
.
+------------------+--------------------------------------------+
Flush .
+------------------+--------------------------------------------+
Getdir -
.
+------------------+--------------------------------------------+
IResult , -
-
-.
+------------------+--------------------------------------------+
MkDir .
+------------------+--------------------------------------------+
Read
.
+------------------+--------------------------------------------+
Readln , Read, -
.
+------------------+--------------------------------------------+
Rn .
+------------------+--------------------------------------------+
Rset .
+------------------+--------------------------------------------+
Rewrit .
+------------------+--------------------------------------------+
RDir .
+------------------+--------------------------------------------+
Seek -
. -
.
+------------------+--------------------------------------------+
SeekEof
" ".
+------------------+--------------------------------------------+
SeekEoln
" ".
+------------------+--------------------------------------------+
SetTextBuf -
.
+------------------+--------------------------------------------+
Truncate .
.
+------------------+--------------------------------------------+
Write .
+------------------+--------------------------------------------+
Writeln , Write, -
.
23. .
, .
Procedure name( :<>);
Function name( ):
, .
-: y=sin(x);
( var ) . , .
. RS-.
RS - [10][11], SR- , . ( )
Procedure Trigger(R,S:Boolean;var q,noq,error:Boolean);
Begin
Error:=randS;
If not error then
If r then q:=false
Else
If s then q:=true;
Noq:=notq;
End;
Var r,s,q,notq,error:Boolean;
Begin
Q:=false;
Notq:=not q;
For r:=false to true do
For s:=false to true do begin
Trigger(r,s,q,notq,error);
If error then writeln(byte(R):3,byte(s):3,);
Else writeln(ord(r):3,ord(s):3,ord(q):3);
End;
End.
.
random. - randomize; . Randomize , . , random .
random 0 () . , 0 ( ). random (10), , [0, 10). - ( ), . , -100 100 : random (200) 100. , [0, 199], . 100, .
, , , .
.
.
.
Prodram TestForward;
Procedure Flop(N:Integer);Forward;
Procedure flip(N:Integer);
If N>0 then begin
Writeln(Flop); flop(n-1);
End;
End;
Procedure flop(N:integer);
Begin
If n>0 then begin
Writeln(flop);
Flip(n-1);
End;
End;
Begin
Flop(3);
End.