.


:




:

































 

 

 

 





, :

, -, . , , .

// 0 - 0

for (i=1; i<20 &&! ( A[i-1]<0 && A[i]>0 ); i++);

break , , , ;

for (int i=0; i<20; i++){ //

if (A [ i ]<0) break; //

...}

for (int i =0; i <20 && A [ i ] >= 0){ //

...} //

, , :

// , 0

for (i =1;! (A [ i -1]==0 && A [ i ]==0); i ++)...

// , 0

for (i=1; A[i-1]!=0 || A[i]!=0; i++)...

-----------------------------------------------------------------------------------------

:

( ); , , , N ..

( , ); , .

 

, , , ( ++ break) ( ++ continue).

++ ( while, do while, for).

     
 


-----------------------------------------------------------------------------------------

:

:

( ) ;

- ;

-
;

- ;

- ;

(, )

( ).

: ( ) ( ) ( ).

, (), ( ). ( ) .

: x = xn (h) xk xn h xk, .. xn, xn+h, xn+2*h, , xn+k*h; :

x=xn;

x=+h; ( , ≤ xk;)

xn xn+h xn+2*h xk=xn+k*h

x=xn x+h x+h x+h

 

( ):

 

while = *2 =17.7, xn = 25.5 xk = 35.5 h = 1.0.

#define _USE_MATH_DEFINES

#include <math.h> //

#include <stdio.h> // /ࠠ

#include <conio.h> // _getch()

 

int main ()

{

double a = 17.7, xn = 25.5, xk = 35.5, x, y, h = 1.0;

// xn , xk

const double X _ end = xk + h/2; //
// xk

x = xn;

 

while (x < X_end)

{

y = a*x*x; //

printf ("x=%7.2lf y=%10.2lf\n", x, y);

x += h; //

_getch(); // ,

//

}

return 0;

}

:

x= 25.50 y= 11509.42

x= 26.50 y= 12429.82

x= 27.50 y= 13385.63

x= 28.50 y= 14376.82

x= 29.50 y= 15403.42

x= 30.50 y= 16465.42

x= 31.50 y= 17562.82

x= 32.50 y= 18695.63

x= 33.50 y= 19863.82

x= 34.50 y= 21067.42

x= 35.50 y= 22306.42

 

-----------------------------------------------------------------------------------------

n

= n =2, n=3:

int n = 3, a = 2;

int p = 1, k = n;

while (k > 0)

{ p *= a;

k --;

}

. :

n=3; a =2;
p=l; k=3;
// 렠 à k>0: true;
//
=1*2; k=3-l; // p=2; k=2
/*
à k>0: true; */
//
p=2*2; k=2-l; // p=4; k=l
/*
à k>0: true; */
//
=4*2; k=l-l; // p=8; k=0
/* }
à k>0: false, */
//

 

 

=2, n=0 :

=1; k=0;
// à k>0: false;
//

 

-----------------------------------------------------------------------------------------

. while :

int x, y, z;

x = y = 0;

while (y < 10) ++y; x += y; printf ("%d %d\n", x, y); //x=10, y=10

 

x = y = 0;

while (y < 10) x += ++y; printf ("%d %d\n", x, y); //x=55, y=10

 

y = 1;

while (y < 10) {x = y++; z = ++y;} printf ("%d %d %d\n", x, y, z);
//x=9, y=11, z=11

-----------------------------------------------------------------------------------------

do while = *2 =17.7, xn = 25.5 xk = 35.5 h = 1.0.

 

#define _USE_MATH_DEFINES

#include <math.h> //

#include <stdio.h> // /ࠠ

#include <conio.h> // _getch()

 

int main ()

{

double a = 17.7, xn = 25.0, xk = 35.0, x, y, h = 0.5;

const double X _ end = xk + h/2; //
// xk

x = xn;

do

{

y = a*x*x;

printf ("x=%7.2lf y=%10.2lf\n", x, y);

_getch(); // ,

//

x += h;// !!!

 

} while (x < X_end);

return 0;

}

-----------------------------------------------------------------------------------------

for = *2 =17.7, xn = 25.5 xk = 35.5 h = 1.0.

 

#define _USE_MATH_DEFINES

#include <math.h> //

#include <stdio.h> // /ࠠ

#include <conio.h> // _getch()

 

int main ()

{ double a = 17.7, xn = 25.5, xk = 35.0, x, y, h = 0.5;

const double X _ end = xk+h/2; //
// xk

for (x = xn; x < X_end; x+=h)

{ y = a * x * x;

printf ("x=%7.2lf y=%10.2lf\n", x, y);

_getch();

}

return 0;

}

 

#define _USE_MATH_DEFINES

#include <math.h> //

#include <stdio.h> // /ࠠ

#include <conio.h> // _getch()

 

int main ()

{

double a = 17.7, xn = 25.5, xk = 35.0, x, y, h = 0.5;

const double X _ beg = xn - h/2; //
// xn

for (x = xk; x > X_beg; x -= h)

{

y = a * x * x;

printf ("x=%7.2lf y=%10.2lf\n", x, y);

_getch();

}

return 0;

}

 

 

#define _USE_MATH_DEFINES

#include <math.h> //

#include <stdio.h> // /ࠠ

#include <conio.h> // _getch()

int main ()

{

double a = 17.7, x, y, h = 0.5, xn = 25.5, xk = 35.0;

const int k = int((xk-xn)/h)+1; // floor ((xk-xn)/h)+1;

x = xn;

for (int i=1; i<=k; i++)

{

y = a * x * x;

printf ("x=%7.2lf y=%10.2lf\n", x, y);

x += h;

_getch();

}

return 0;

}

-----------------------------------------------------------------------------------------

, . , .

- , , .

 





:


: 2018-10-15; !; : 532 |


:

:

, .
==> ...

1668 - | 1487 -


© 2015-2024 lektsii.org - -

: 0.034 .