.


:




:

































 

 

 

 





. ( ) . : .

, ;.

" " " ", " ", :

_ (__);

. : 1) ; 2) ; 3) ; 4) .

. , . . , :

{

n++;

summa+=(float)n;

}

:

{

int n=0;

n++;

summa+=(float)n;

}

.

(if) (switch).

(while), (do) (for).

: goto ( ), continue ( ), break ( ), return ( ).

:

if (_) ;

_ : , . , , (.. ) _. :

if ( < 0 && > -10) =-;

, :

if {_)

_1;

Else

_2;

- _1, - _2.

:

if ( > 0) b=; else b=-;

if, _1 _2 if , .

. , ":". ,

label: z+=-8;

( ), , ";"

. :

goto ;

.

.

( stdio.h):

scanf ( _, _);

scanf() "" , . , , . scanf() , . . , scanf() . scanf() :

% * _

% . :

d ( int);

u ( unsigned int);

f ( float);

( float).

_ , , () .

'*' .

:

h short int (hd);

l long int (ld) double (lf, le);

L long double (Lf, Le).

printf() scanf() , .

, n, z, :

scanf ("%d%f%f",&n,&z,&x);

. , . n , z float, 18 18 -0.431 n 18, z- 18.0, -0.431.

<Enter> () , .

, , .

1.

/* :*/

/* r h.*/

/* :*/

#include<CONIO.H>

#include<STDIO.H>

#define pi 3.1415 /* π*/

void main(void) /* */ {

float r,h,v,s;/*v - , s */

clrscr(); /* */

printf(" : ");

/* */

scanf("%f",&h); /*

*/

printf(" : ");

scanf("%f",&r);

v=pi*r*r*h; /* */

s=2*pi*r*h;

printf("\n =%f",v);

printf("\n \

=%f",s);

printf("\n ...");

getch(); /* */

}

2.

/* .*/

#include<CONIO.H>

#include<STDIO.H>

#include<STDLIB.H>

#include<MATH.H>

void main(void){

int num, /* */

i,j,k,l, /* */

p; /* */

clrscr(); /* */

printf(" : ");

scanf("%d",&num);

num=abs(num);

printf(" %d: ",num);

i=num/1000;

j=num/100%10;

k=num/10%10;

l=num%10;

printf("%d %d %d %d\n",i,j,k,l);

p=i*j*k*l;

printf(" %d : %d",num,p);

printf("\n ...");

getch(); /* */

}

3.

:

, Î(0;19] Da=0.5.

#include<STDLIB.H>

#include<CONIO.H>

#include<STDIO.H>

#include<MATH.H>

void main(){

float a,y,da,a1,a2;

int i=0;

clrscr();

printf(" :");

scanf("%f",&da);

printf(" :");

scanf("%f",&a1);

printf(" :");

scanf("%f",&a2);

for(a=a1;a<a2;a+=da){

i++;

if(1<a && a<5)/* : 1<a a<5 */

{y=a;printf(" a=%.2f y=%.3f",a,y);}

if(9<a && a<19)

{y=a*a;printf(" a=%.2f y=%.3f",a,y);}

if(a>=5 && a<=9)

{y=a*a*a;printf(" a=.2%f y=%.3f",a,y);}

printf("\n");

if(i>24)

{getch();i=0;}

}

getch();

}

:

1. , , .

2. . .

3. . . .

4. . . .

5. . .

6. . .

7. #include<> #define.

8. .

9. .

:

1. , . .

2. . .

3. . .

4. . .

5. , . .

6. , A, B, C . .

7. . , [a,b].

8. , . .

9. , b, c , ax2+bx+c=0, .

10. , .

11. , .

12. . , .

13. 12 , .

14. . , .

15. , , . .

16. , x, y, z. .

17. , x, y, u, w. .

18. .

19. . . , . .

20. ax=b.

21. , x, y.

22. k- . , . .

2

:

(4 )

, while, for, do.

for () , .

while () , .

while for :

_

_

, , . . , {}. .

while ( ) :

while (_)

_

_ . , . . 0, , _ . ( ). , _ . _ . , _ 0.

:

...

i=2;

b=1.0;

r=x;

while(r>eps || r<eps)/* || */

{

b=b+r;

r=r*x/i;

i++;

}

for () :

for(_1;_;_2)

_

for , . _1 , , . . ; . _ . . _2 . _2 _ . , _1 , _ _2 . , _. for , ; . _, , . for _1 , , , :

:

b=1.0;

r=x;

for(i=2;r>eps||r<-eps;i++){

b=b+r;

r=r*x/i;

}

:

for(i=2,b=1.0,r=x;r>eps||r<-eps; b+=r, r*=x/i, i++);

.

do ( ) :

do

_

while (_)

_ , while. do , , . _ ( 0), (. . 0), . .

:

i=1;

b=0.0;

r=1.0;

do {

b=b+r;

r=r*x/i;

i++;

} while (r>=eps || r<=-eps);

:

1. for.

2. while.

3. do.

4. break.

5. continue.

:

1. Z=1+2+3+.... , Z .

2. a1, a2,...,aN, i=random(N). ( ), .

3. i=1/i. i.

4. N. , .

5. N. N : 1/2*7/8*13/14*19/20*....

6. .

7. N.

8. .

9. .

10. Z=1+2-3+4-5.... , Z .

11. z=(a+b)/i, 0 1, b 5 1, i=1,...,N. b i.

12. . 1, 1+1/2, 1+1/2+1/3+... , .

13. sinx+sin2x+...+sinnx

14. F0=F1=1; Fi=Fi-1+Fi-2 i=2,3,... , (>0).

15. sinx+sinx2+...+sinxn

16. , ( , ).

17. a, b, c, d y=ax3+bx2+cx+d , . x 0 2 0,2.

18. , .

19. N. i3-3*i*N+N, i=1,2,...,N, .

20. . , 0.

3

: .

(4 )

, . :

_ _ [ ];

(sizeof()* _) . 0, . . 0 N-1, N .

, :

_ [ _ ].

:

char name [20];

int grades [125];

float income [30];

double m [1500];

, , , . . , float Z[13][10] Z 13 -, , , 10 float.

, . . , . , 31.

, . . . . . , , :

int m[]={1,2,3,4,5};

m[0]=1, m[1]=2, m[2]=3, m[3]=4, m[4]=5.

int m1[3][2]={{1,2},{3,4},{5,6}};

m1[0][0]=1, m1[0][1]=2, m1[1][0]=3, m1[1][1]=4, m1[2][0]=5, m1[2][1]=6. :

int m1[3][2]={1,2,3,4,5,6};

. , , . , . .

. , , . . .

:

for( ){

1;

N;

for( ){

1;

N;

}

}

while dowhile.

while(){

1;

N;

while(){

1;

N;

}

}

break continue. , . break . continue .

( ), , / .

:

1. .

2. .

3. .

4. .

5. break continue .

:





:


: 2016-03-28; !; : 550 |


:

:

.
==> ...

1427 - | 1398 -


© 2015-2024 lektsii.org - -

: 0.141 .