P. 1
Pascal

Pascal

|Views: 48|Likes:

More info:

Published by: Валентин Валентинович on Mar 23, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as TXT, PDF, TXT or read online from Scribd
See more
See less

03/23/2011

pdf

text

original

Boolean

:
Ïðèìåð ==> a:=2>4 ==> False;
<> - íå ðàâíî
Ôîðìàòèðîâàíûé âûâîä:
writeln(x:5:3);
if else:
Ïðèìåð 1:if (x>y) then writeln ('÷èñëî x áîëüøå') else writeln ('÷èñëî y áîëüøå');
Ïðèìåð 2:if (x>y) then
Begin
writeln ('÷èñëî x áîëüøå');
writeln('Êàêîå íèáóäü ñîîáùåíèå');
End
else
Begin
writeln ('÷èñëî y áîëüøå');
writeln('Êàêîå íèáóäü ñîîáùåíèå');
End;
Ñòðóêòóðà èñïîëüçóåòñÿ è áåç else.
Ñîñòàâíûå óñëîâèÿ:
if ((x>y) and (z>Q)) then ....
Òàêæå âîçìîæíî èñïîëçîâàíèå èñëîâèÿ ñ îïåðàòîðàì or.
Âëîæåííûå óñëîâèÿ:
if (x>y) then
Begin
if (z>2) then writeln('ñîîáùåíèå') else writeln('ñîîáùåíèå 2');
writeln ('÷èñëî x áîëüøå');
writeln('Êàêîå íèáóäü ñîîáùåíèå');
End
else
Begin
writeln ('÷èñëî y áîëüøå');
writeln('Êàêîå íèáóäü ñîîáùåíèå');
End;
Îïåðàòîð âûáîðà Case:
Ïðèìåð:
case a of
0: writeln('Íîëü');
1: writeln('Îäèí');
2: writeln('Äâà');

else writeln('×èñëî íå ñ äèàïàçîíà îò 0 äî 2');
end;
Îïåðòîð GOTO:
uses ....
label metka;
var ...
BEGIN
metka : writeln('Ââåäèòå öèôðó');
case a of
0: writeln('Íîëü');
1: writeln('Îäèí');
2: writeln('Äâà');

else
BEGIN
writeln('×èñëî íå ñ äèàïàçîíà îò 0 äî 2');
goto metka;
END;
end;
Îïåðàòîð while do(Öèêë):
writeln('Ââåäèòå êîëè÷åñòâî ÷èñåë');
read(N);
S:=0; i:=1;
while (i<=N) do
BEGIN
writeln('Ââåäèòå',i,'÷èñëî');
readln(x);
S:S+x;
i:=i+1;
END;
writeln('Ñóììà ÷èñåë:',S);
Îïåðòîð REPEAT UNTIL(öèêëè÷åñêèé);
repeat
writeln(Ââåäèòå ÷èñëî);
read(Num);
s:=S+num;
until (S>=10);
writeln(S);
Îïåðàòîð For:
for i:=1 to 5 do writeln(i);
for i:=5 downto 1 do writeln(i);
Òèï äàííûõ Char:
Äîïóñêàåòñÿ ñðàâíèâàíèå ñòðîâ ñ äàííûì òèïîì äàííûõ òàê êàê ñðàâíåíèå èäåò ïî êîäó ñèìâîëà.
Ïðîöåäóðû:
program...
uses...
procedure write_proc;
var local1:string;
Begin
local1:='Òåêñò';
writeln(local1);
end;
BEGIN
write_proc;
END.
Ôóíêöèÿ TextColor - îêðàøèâàåò òåêñ â íóæíûé öâåò ==> êîäû öâåòîâ ñ 1 äî 15 â help.
TextColor(12);
Ôóíêöèè:
program...
uses...
procedure write_funct:string;
Begin
write_funct:='Òåêñò';
end;
BEGIN
writeln(write_funct);
END.
×òîáû îñóùåñòâèòü ïåðåäà÷ó äàííûõ ôóíêöèè òðåáóåòñÿ óêàçàòü íóæíûå çíà÷åíèÿ â ñêîáêàõ.
Ñîçäàíèå ñîáñòâåííîãî ìîäóëÿ:
unit modul;
interface
uses crt;
var a,b:integer;
SumNum:integer;
procedure summa2(var sum: integer; a,b:integer);
function summa1(a,b:integer):integer;
implementation
procedure summa2(var sum: integer; a,b:integer);
BEGIN
sum:=a+b;
end;
function summa1(a,b:integer):integer;
begin
summa1:=a+b;
end;
end.
Ìàññûâû
Îäíîìåðíûå ìàñèâû:

.. Îïåðàòîð while do(Öèêë): writeln('Ââåäèòå êîëè÷åñòâî ÷èñåë'). for i:=5 downto 1 do writeln(i). Îïåðàòîð For: for i:=1 to 5 do writeln(i). s:=S+num. while (i<=N) do BEGIN writeln('Ââåäèòå'.S). BEGIN metka : writeln('Ââåäèòå öèôðó'). Îïåðòîð GOTO: uses . writeln('Ñóììà ÷èñåë:'. label metka. read(Num). until (S>=10). repeat writeln(Ââåäèòå ÷èñëî). S:S+x. end. else BEGIN writeln('×èñëî íå ñ äèàïàçîíà îò 0 äî 2').. Îïåðòîð REPEAT UNTIL(öèêëè÷åñêèé). . i:=i+1. readln(x). goto metka. writeln(S). 1: writeln('Îäèí'). read(N). var .. case a of 0: writeln('Íîëü').end.. END. S:=0. END. 2: writeln('Äâà').'÷èñëî').i. i:=1.

You're Reading a Free Preview

Descarga
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->