WWW.DISSERS.RU


...
    !

Pages:     | 1 |   ...   | 5 | 6 || 8 | 9 |   ...   | 21 |

Sscanf (cpoa, "ec c opaa ox eeo", cco apeco eeo);

opoee o oe oe acae.

Haaee Writeln ac (o) opa a pa. B opa poeyp:

Writeln (ee, ee,....);

eeo oe :

- aee eoe eeceoe (writeln (3);) - co (writeln (a);) - cpoo (writeln (pe p);) - yec aee (writeln (false);) - eoao ocao (writeln (a);) - ye (writeln (cub);) - yaaee (writeln (Aptr^);).

Bce ee eaac cpoy aao ope. oce oa ypcop ycaaaec a aao ceye cpo. Ec ec eoxooc oca ypcop o e cpoe oce oceeo eea, o coyec:

Write (ee, ee,...);.

p oe eeo c oo poeyp Writeln ey aoaec poe e cac. p ea e x eoxoo yec:

Writeln (ee, ' ', ee, ' ',....);

puep:

B popae: Ha pae:

Var A, B, C: Integer;

Name: string;

Begin A:= 1; B:= 2; C:= 3;

Name := 'Frank';

Writeln (A, B, C); Writeln (A, ' ', B, ' ', C); 1 2 Writeln ('Hi', Name); HiFrank;

Writeln ('Hi, ', ' Name.'); Hi, Frank.

Moo cooa apaep opeee p o aoo eea. B o cyae oepaop ee opa:

Writeln (ee: a,....);

e a eoe paee (epa, ocaa, epeea, o y), opeeee o paep o oa eea.

Paccop ceyy popay oye peyae o:

B popae: Ha pae:

A:= 10; B:= 2; C:= 100;

Writeln (A, B, C); Writeln (A:2, B:2, C:2); 10 Writeln (A:3, B:3, C:3); 10 Writeln (A, B:2, C:4); 10 2 100.

ee ooec aa poea cea cooec c yaao o. Cao aee paaec cpaa.

Ec paep o aa ee, e eoxoo, o p oe aca yeae paep o ao eoxooo. Bo opo oepaope Writeln epeeoo pepa C = 100, a o ee, e yo, .e.

aao 2, a yo 3.

o eo pe cex oycx eeo: eoo a, eecex ce, coo, cpo yecx o. Oao, p yaa p (paepa) o eecex ce paae pocxo cea paceaaec coeao ope.

B popae: Ha pae:

x:= 421.53;

Writeln (x); 4.2153000000E+02;

Writeln (x:8); 4.2E+02.

ooy, aca oae opo oepa :

ee : a : oeco p.

Bopa pa yaae, coo p o ca c cpoao oo oce o:

B popae: Ha pae:

x:= 421.53;

Writeln (x:6:2); 421.Writeln (x:8:2); 421.Writeln (x:8:4); 421.5300.

B caapo acae ec e ocox poeyp oa opa Read Readln, oope coyc e ax c aayp.

x opa:

Read (ee, ee,...);

Readln (ee, ee,...);, e a ee o epeea eoo, eeceoo, cooo a cpoa. ca o oec py o pya poea aae a Enter.

puep :

Uses Crt; {Bee oy} var a : integer; {ocae epeeo a-ea} b : real; {ocae epeeo b-eecea} Begin {aao ea popa} ClrScr; {oca paa} Write (Bee aee epeeo a =);{o cooe a pa} ReadLn (a); {o ae epeeo} b:= a/3;{oepaop} WriteLn ('b =', b:5:3);{o} ReadLn;{peya pao popa ye a pae o ex op, oa e ye aaa aa Enter} End.{oe ea popa} BE PBEEH PMEP POPAMM HA ACAEC COOBAHEM OEPATOPOB BBOABBOA.

popaa, acaa a C, coya y oa-oa, oa a ce a stdio.h c oo oa pepoeccopa #include a stdio.h coep:

1) opeeee a ax FILE;

2) opeeee apaepo, coyex apooax oax oex y oa-oa.

opapoa o o ocyec a ceeca y: scanf oeceae opapoa o, a ceeco printf opapoa o.

fscanf opapoa o aa, scanf opapoa o ooa stdin (aayp), sscanf opapoa o cpo C, fprintf opapoa o oo, printf opapoa o oo stdout, sprintf opapoa o cpoy C.

omo o o a a ce, o ecoe ycpoco, apep, ce eaaee ycpoco.

puep popa coye, y oa-oa a C:

#include /*ee oe*/ main ()/* aa y popa*/ { int a; /* ocae epeeo a -ea*/ double b;/*ocae epeeo -eecea*/ printf ("ee eoe co");/*o eca a pa*/ scanf ("%d", &a); /*o epeeo a*/ b = a/3; /*oepaop*/ printf ("\N b = %lg ", b); /*o ae epeeo b*/ getch (); /*aepa paa*/ } p oe o y C a ee y pyx coax yaaec, o ee epeaec. Bepy y printf epeaec ecoa cpoa, oopa ye eaac a pae oopa. Cpoa C aaec oe a. Bo opo y printf oo cpoe pcycye eeaae ypa o \n, ooaa epeo ypcopa a oy cpoy opa oo epeeo b %lg, caa epeea yaaaec a cpoo oce ao. aee epeeo a pae ye eaac cpoe a ece coa opaa. Bcyae, ec eoxoo aeaa ecoo epeex, o co opaa o ceoa cpoe o-e oceoaeoc, o epeee, ceye a cpoo epecee epe ay. Hanpuep: printf (a=%i b=%lg, a, b); co opaa o cooecoa a epeex (a.7, 8 9).

8 Co opaa oa- oa C CMBO T ooo oea OP MATA %c a char %s co a string %d %i int %o int ocepo e %u unsigned int %ld long eco e %x int ecaaepo e %lo long ocepo e %lu unsigned long %lx long ecaaepo e %f float double c cpoao oo %e float double coeao ope %g float double e F E acoc o ae %lf long float c cpoao oo %le long float coeao ope %lg long float e F E acoc o ae ao epeeo oepa oa-oa oa cooecoa cea cooecyeo a. Ec coyc ecoo epeex, o ce o cooecoa cea cooecyx o.

9 pae o ESC oceoaeoc C \n Hoa cpoa \t opoaa ay \v Bepaa ay \b Bopa a co \r Bopa a aao cpo \a yoo ca O e p a o p p c a a Oepaopo aaec eeapa cpyypa ea popapoa.

Ocoo oepae ec oepa pcaa. B acae oepa pcaa o oa oeo aa paeca: ":=". BC o poco a paeca.

puep:

yc a e epeee x = 2 y = 5, peyec oe a x ae eca a, o x = 5, a y = 2.

oo epec pe epeea z pooc ceye ec:

1) z:=x;

2) x:=y;

3) y:=z;

Ec poec pcoee e cooa z, x:=y, o coepoe e a epeeo x poaae. p o eoxoo o, o pcoee e cpaa aeo, a e aoopo.

A P M E T E C E O E P A O E P A T O P Bce oepa pcaa epee peya ce pae. o: coee (+), ae (-), eee (/) yoee (*), a ae % C mod aca oopa ae ocao o ee. Bce oepa C, a cee ocaa o ee, opeee epeex a int, float, char. Ocao e opeee a float. B acae cyecye oepa div eoceoe eee (i div j- peya pae acoy o ee, opyeoy o eoo). Tae acae, oepac yape oepaop. coyc ceye oepa:

a+ = b a:= a + b;

a-= b a: = a b;

a*= b a:= a*b;

a/ = b a:= a/b;

+ + a yeae aee a a 1 o cooa o epeeo;

a + + yeae aee a oce cooa o epeeo pae;

a yeae aee a a 1 o cooa o epeeo;

a yeae aee a oce cooa o epeeo pae;

sizeof ( coax yaaec epeea) oo pe ocaa. B peyae ye oyeo co a, apaaex oepaopo.

Oepaop ooe cpaa a ae, opaa peyae yecoe aee True False acae 1 0 C.

> oe, e;

>= oe, e pao;

< ee, e;

<= ee, e pao;

= acae, = = C poepa a paeco;

<> acae, != C poepa a epaeco;

puopumem pope apeecx oepa ae e, a aeae. e pope oo pye co.

pope oao y <= >=, o e, e y = = !=. Hanpuep:

If ( (ch=getchar ())>a) y getchar opaae co xoo cpo. oecx oepa pope ca .

He o o p e c a a p e a e a e c e y 10 aca y Haaee Round (x) opyee ae eeceoo a o eoo peopaoae ae eeceoo Trunc (x) a aee eee eoe Abs (x) acooe aee apyea ArcTan (x) opeeee apaeca x Cos (x) opeeee ocyca x Exp (x) opeeee coe apyea Frac (x) opeeee poo ac apyea Int (x) opeeee eo ac Ln (x) opeeee aypaoo oapa Sqrt (x) ope apa Sqr (x) apa apyea Dec (x) yeee epeeo a 1 aaoe aee epaepa N Inc (x) yeee a B acae oee cee coyec ceyee paee:. ac eoopx aeaecx pae:

puep:

+ + = 11 C y Haaee Abs (x) acooe aee apyea ArcTan (x) opeeee apaeca x Cos (x) opeeee ocyca x Exp (x) opeeee coe apyea Log (x) opeeee aypaoo oapa Sqrt (x) ope apa Pow (x, y) oeee ocoa x cee y o c o c a e o e p a o p a oceoaeoc oepaopo C, aea ype co { } aaec cocma onepamopo uu oo. Byp oa a oepaop aaaec;. Cocao oepaop coyec ee, e cacc a oycae cooae pocoo oepaopa.

B acae cocao oepaop axoc ey coa begin end.

y c o o e p a o p ycmo onepamop x ax pecaec coo. yco oepaop coyec a, e cacc a peycapae pcyce oepaopa, a o oe popa oepaop oe ocycoa. B C eoxooc cooa ycoo oepaopa aco oae p popapoa o, oa ec, oope oy oe ee a, eo oeac aooo a.

1 2 O E C E O E P A O E P A T O P oece oepaop: aca C and && or | | e not ! c o e o e p a o p o c p y o p a o oee oo aopa oa, ec oec eoopoe ycoe (, ec ycoe e oec, o oa poycac oec pyo aop oa) ec ee ax ee yaaoe aee aao ae.

BC ce pae, peaye yco ao ocpy opa o aac pye co ().

Oepaop ee C acae pee a. 13 Oepaop ee C acae aca C if ycooe paee then oepaop 1; if (ycooe paee) oepaop1;

If ycooe paee then oepaop 1 if (ycooe paee) else oepaop 2;

oepaop1;

else oepaop 2;

Case paee of switch (paee) ocaoe paee 1: oepaop 1; { ocaoe paee 2: oepaop 2; case ocaoe paee 1:

oepaop 1; brak ocaoe paee 3: oepaop 3;

case ocaoe paee 2:

ocaoe paee n: oepaop n;

oepaop 2; brak end; {case} case ocaoe paee 3:

oepaop 3; brak case ocaoe paee 4:

oepaop 4; brak case ocaoe paee n:

oepaop n; brak default: oepaop;

} He aaoa ycoa oepa Cmu npopaupoau. Oepaop axoec oce aooa yco, epeocc a oy cpoy cac a e o ooceo aooa.

Oepaop if/else pec, oa eoxoo o ac popa, ec aaoe ycoe ee aee True False acae C (1)-co (0) oo, oa aaoe paee pae opeeeoe aee.

Oepaop if:

if paee then oepaop else oepaop 2, e paee oe yecoe paee (paaaee peyae True False); oepaop 1 oepaop 2 oepaop aca. Ec paee pae aee True, o oec oepaop 1; poo cyae oepaop 2.

Oepaop oe coca, .e. coco ecox oepaopo (cop o oepaopo), yc (cop yco oepaop). Ec aooe paee ycooo oepaopa paaae yeoe aee, o ypaee epeaec ceyey oepaopy. Ec paee paaae e yeoe aee, o oec oepaop, co oce ycooo pae. B oepaope aca epe coo else e o c ao, a cacc C peye o ece oy c ao ycooe paee, opaeoe py coa.

if ( ycooe paee) oepaop 1;

else oepaop 2;

Cacc a C peycapae, o else cea oocc aey if.

puep:

int i = 4, j = 6, k = 8;

if (i < k) if (i > j) printf ("oepaop 1");

else printf ("oepaop 2");

ocoy epo pae ca, a o opo o, o popaa aeaae oepaop 2.

a ax oea, a oope ceye opa ae p cooa if/then/else.

Bo-epx, oepaop else e ec oae, py coa, oyco cooa oepaop if ceye e:

if paee then oepaop if (ycooe paee) oepaop 1;

Pages:     | 1 |   ...   | 5 | 6 || 8 | 9 |   ...   | 21 |



2011 www.dissers.ru -

, .
, , , , 1-2 .