WWW.DISSERS.RU


...
    !

Pages:     | 1 |   ...   | 7 | 8 || 10 | 11 |   ...   | 21 |

Readln (A, B);

Ratio := A / B;

Writeln ('Ooee pao', Ratio);

Writeln ('oop (Y/N)');

Readln (Ans);

until Upcase (Ans) = 'N';

end.

Bo popae oopec oee oepaopo, oa oe a opoc N (oop Y/N). py coa repeat until, oopc, o ex op, oa aee pae p until e ye True.

Cacc a:

repeat oepaop;

oepaop;

........

oepaop;

until paee.

Cyecy p ocox o oo a o a while:

- oepaop e repeat oc xo o pa, ooy o poepa pae ocyecec oe ea a. B e while, ec aee pae False, eo eo poycaec cpay repeat oec oa paee e cae True, o pe, a while oec o ex op, oa paee ee aee True. p aee ooo a a a pyo eoxoo a o opaa ocooe ae. Paccop popay HELLO, e while aee a repeat:

program Hello; {aao popa} var Count: Integer; {ocae epeeo (ea)} Begin {aao ocooo oa popa} Count := 1; {pcoee aaoo ae} Repeat {aao a} Writeln ('pacy poa!'); {o cooe a pa} Inc (Count); {yeee ae epeeo a 1} until Count > 10; {oe a} Writeln ('o oe'); {o cooe a pa} end. {oe popa} Oe, o eep epeea Count poepec a aee, oee 10 (a while o Count <= 10).

B e repeat oe cooac poco pya oepaopo, a e cocao oepaop. p cooa oo a e coyc coa begin...end, a cyae c o while.

Oepaop a repeat oc xo o pa, o pe, a oepaop a while oy pay e oc acoc o ae pae.

O e p a o p b r e k, c o n t i n u e, r e t u r n break Oeceae pepaee oe caoo ypeeo oex eo oepaopo ax, a switch, do while, while, for, repeat/until, case (.e. eeeoe pepaee pao a). oce oe oo oepaopa ypaee epeaec oepaopy, ceyey a pepa.

continue Paoae ooo oepaopy break, o o o eo, continue pepae oee ea a epeae oee a ceyy epa (a).

pep:

for (n=0;n<100;n++) { if (n%2!=0) continue;

printf ("%d", n);

} oa n caoc eeo, paee n%2!=0 oyae aee 1 oec oepaop continue, oop epeae ypaee a ceyy epa a for e o oepaop printf.

Oepaop continue, ae a break pepae ca ype oex eo o ( cyae oex o).

return aepae oee y, oopo o aa opaae ypaee ay y oy, ceyy a oo y.

return (paee);

aee pae, ec oo aao opaaec ay y, aece ae ae y. Ec coax paee oyeo, o ypaee aoaec epeaec aey y oce oe oceeo oepaopa y (aeo). Bopaaeoe ye aee o cyae e opeeeo.

Ec y e opaae ae, o ee ceye o o void.

1) return coy: ec ao y;

2) ec y opaae aee.

puep 1:

int sum (int a, int b) { return (a+b);

} main () { int a=2, d=4;

int s;

s=sum (a, b);

} puep 2 (y, oopa o-o eaae):

void print (char x) { if (x==0) { printf ("oxo apye");

return;

} printf ("pyo apye");

printf ("%c", x);

} Oepaop return coyec xoa y printf, ec apye pae y.

P O E P H C T P T P A P O E P H B A C A E B acae ec a a opopa: poeyp y. aoe pae ey o o, o y opaae aee oe cooaa pae:

x := sin (A);

o pe, a poeypa oo oe aa:

writeln ("o poepa");

poeyp y, ece o o ee a opopa oy oca o ece popa, o o ea ao popa. opa poeyp:

procedure poeyp (apaep);

label e;

const oee oca;

type opeee o ax;

var oe epeex;

procedure function;

begin eo ao poeyp;

end;

y e ao e opa, a poeyp, oo o aac c aooa function aaac o ax opaaeoo ae:

function y (apaep): ax;

ec oo a pa ey popaa poeypa y:

- poeyp y e aooo procedure function, cooeceo, a e program;

- poeyp y aaac oo c ao (;), a e oo (.).

poeyp y oy e oca cox oca, o ax, epeex co poeyp y. Ho ce ee oy cooa oo ex poeypax yx, e o oe.

puep y pacea aopaa Function fact (n: integer): real;

f:=1;

for i:=1 to n do f:= f*i;

fact:=f;

end.

puep: poeyp pacea cy pa S = i i = Procedure sum;

Var i: integer;

S: real;

begin S:=0;

for i=1 to 10 do S:= S+i;

Write (S);

End.

pep cppy oc poeyp y acae.

puep: poeyp oye yx ae y, opee x ooee:

program DoRatio;

var A, B: Integer;

Ratio: Real;

procedure GetData (var X, Y: Integer);

begin Writeln ('Bee a ca:');

Readln (X, Y);

end;

function GetRatio (I, J: Real);

begin GetRatio (I / J);

end;

begin GetData (A, B);

Ratio := GetRatio (A, B);

Writeln ('Ooee pao ', Ratio);

end.

o pep oaae, a coyc paoa poeyp y.

oce o ayca popa ep oec oepaop GetData (A, B). o oepaop ece a o poeyp. p opaoe oa oc oepaop GetData, p o X Y (opae apaep) aec a A B (aece apaep). eoe coo var epe X Y oepaope oa GetData oop o o, o aece apaep o epee o ae epeex oy ee opae ae popae. p aepe pao GetData ypaee opaaec ay popay a oepaop, cey a oo GetData.

Cey oepaop o y GetRatio. Oe eoope o. Bo-epx, GetRatio opaae aee, oopoe oo cooao; o cyae, oo pcaaec Ratio. Bo-opx, aee pcaaec GetRatio ao popae; y opeee, aoe aee opaaec. B-pex, e eoo coa var epe opa apaepa I J. o oaae, o o oy eoce pae, a a Ratio:= GetRatio (A+B, 300); o ec ae x ae yy ee y, o oe ae e opac opao ay popay.

ca, o e ec oe poeyp o y. Moo cooa oa a apaepo oox o popa.

H B C B e C e o poeypa. yue aaec eaca cooyoc oe oepaopo, peaaea oe opeeeo aa.

aa y oa e , oopoe coyec oa y. oo y a C main. o apeeppoao oo pcycoa o popae a C. B popae oy pcycoa pye y, p o main e oaeo oa epo. Xo eo c y main aaec oee C-popa. p oe y e oy epea ae ocpeco apyea y. y oe opaa ae. o aee ec ocoo peya oe y, oop p oe popa ocaec a eco y. Bepy oo oo oo aee. Moy a e opeec y, oope e e ax apaepo e opaa aoo ae. C cooae y C ca 3 o:

1 oee y;

2 opeeee y;

3 o y.

Oeue y poo aae y, co ee apaepo, oe oepaop, oope opee ec y. Boe y a e oe aa ae opaaeoo ye, a a e ceaop acca a y (c. pae 5.11.1).

B e C e peoa, o opeeee y oaeo peecoao oy y. Oao, oo, o oop o o poepy cooec o, epeaaex apyey o opax apaepo opeee y, o oa y yo oec oee o y. o oee aaec pooo. pomomun y ee o e opa, o opeeee y c o pae, o e ee ea y oe aaac " ; ". oceoaeoc oe oepaopo aaec eo y.

Ec oee y e aao, o o yoa cpoc poo a ocoa opa epo cc a y, y o o y opeeee. Oao, ao poo oe eaeao peca ocey o opeeee y. aae pooa ooe oopy aa aocece cooe o oe, o oppe opao peypoa ecooece apyeo.

Onpeeeue y aae opax apaepo eo y. Oo oe opee opaaeoo ae acc a y.

Cacc opeee y: [ceaop acca a] [ceaop a opaaeoo ye ae] y ([ ea opax apaepo] {Teo y} acc namu yuu oe o ca, o cep. Ec acc a y e yaa, o o yoa caec cep.

Tun opama cac, oa y opaae aee. Ec ceaop a e aa, o o yoa cac int. Ec y e opaae aoo ae, o cac void. Ocae y oe aa co eoo, o oaae, o y opaae yaae. y e oe opaa acc y, o oe opaa yaae a o .

Cnuco opax napaempo o oceoaeoc oe opax apaepo, paeex a. opae napaemp o epeee, oope pa ae, epeaaee ye o pe oa. ooe oee opax apaepo y aaec pyx coax, ceyx a ee y opeee y. ee cca opax apaepo ee a opaa.

1 Ceaop a;

2 Ocae aaec epe ae, o oy oaac coa:,... eopeeeoe co apaepo. o oaae, o co apyeo y epeeo. Ec y e epeae apaep, o ec (void). opo opax apaepo o o e e opeee y o cex oex.

puep. Paccop p a y ce ya ca. y y = x3.

1. y epeaec apaep oa opaae apaep #include int cub (int x); // oee y;

int cub (int x) // opeeee y { int y;

y=xxx; eo y;

return (y);

} void main (void) { int x;

int y;

scanf ("%d", f x);

y=cub (x); o y;

printf ("%d", y); getch ();

} 2 y epeaec apaep, o oa eo e opaae #include void cub (int x); // oee y;

void cub (int x) // opeeee y;

{ int y;

y=xxx; // eo y;

printf ("%d", y);

} void main (void) { int x;

int y;

scanf ("%d", f x);

cub (x); o y; getch ();

} 3 y eo e epeaec oa eo e opaae #include void cub (void); // oee y;

void cub (void) // opeeee y;

{ int y, x;

scanf ("%d", &x); // eo y;

y=x*x*x;

printf (%d, y);

} void main (void) { cub (); // o y;

} Teo yuu cocao oepaop, coepa oepaop, opeee ec y. O a e oe coepa oe epeex, coyex x oepaopax cooeceo. apaep y epeac o ae, oy paccapac a oae epeee, eco oopx pacpeeec p oe y.

O apyc ae epeax apyeo epc p xoe y. ooy ee y e e ae apaepo, a a y paoae c o apyeo. Oao, ec aece apaepa epea yaae epeeo oo cooa oepa pa apeca o epeeo (c. pae 5.11.1). ocyece ocya ee ae o epeeo (c. a. 16).

Ta a apaep y, acao epao, paee ye c o epeaaex apaepo, oa oeae ae x apaepo, e oaa a aee apyeo, a y e oe coe aa. paa paoa y aaec o, o p oe y e o epeaac aece apyeo apeca epeaaex x y, ae oopx yo oe.

puep.

H OMEHA BX EPEMEHHX P AB HO HEP AB HO void chen (int*x, int*y) Void chen (int x, int y) { { int buf; int buf;

buf=*x; buf=x;

*x=*y; x=y;

*y=buf; y=buf;

} } Bo y ee cey opa:

y ([cco epeaaex apaepo cco pae]).

Cco epeaaex apaepo cco pae pecae coo cco aecx apyeo, oope ocac y. aec apye oe o eo ocooo a (cpyypo, yaaee, epecee), xo acc y e oy apaepa y. Ho yaae a acc oy epea y.

Boee oa y pocxo cey opao:

Pages:     | 1 |   ...   | 7 | 8 || 10 | 11 |   ...   | 21 |



2011 www.dissers.ru -

, .
, , , , 1-2 .