.


:




:

































 

 

 

 


. , , ,




 

, , , , , . , , , . , , .

, , n , .

// 27

// n, n 0

double power(double , int n) //

{ // ...

double result = 1.0; //

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

result *= x;

return result;

} //...

. - :

double power(double , int n) //


, .

( - double).

( - power).

, ( - n, double int ).

, , , double , .

: - double, , n - int. , , - result, . , .

.

:

_ _ (_)

 

_ . , void. void , , , :

void my_function(void)

, , void :

void my_function ()

void .

, . result, 1.0. result , , . , result , . : result , ? , , , .

for. i , , 1 n. result , n , . n 0, , false, result 1.0.

, , . , . , , , .

, , , . , . , - , static. return

return result . return :

return ;

, . , , , . , .

void, return . :

return;

, , - , . , , , . , , - , , .


 

, , , . , , . , , , . , , .

, , , , . , , , .

power () :

double power(double value, int index);

He ! .

, , . , . , , .

, , , .

:

double power(double, int);

, , . (, , index power () double), , , .


 

// 28

//,

#include <iostream.h>

double power(double x, int n); //

 

void main ()

{

int index = 3;

double x = 3.0;

double y = 0.0;

y = power(5.0,3); //

cout <<endl << 5.0 v kube = <<y;

cout <<endl

<<3.0 v kube =

<< power(3.0, index); //

x = power (x, power(2.0, 2.0));// // . . 2-

cout << endl << x = <<x;

cout <<endl;

}

// x n, n 0

 

duble power(double x, int n) //

{ //

double result = 1.0;

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

result *=x;

return result;

} //

 

#include - power (). main (), .

void main (), , , . void , , . void, return ; .

power () 5,03 :

= power (5.0, 3);

 

5.0 3 - . , , .

power () n, . , , 125, main (), . , .

:

cout <<endl<< 5.0 v kube = <<y;

:

cout <<endl

<<3.0 v kube =

<<power(3.0, index); //

, , . , . - , - .

power () :

= power(, power(2.0, 2.0)); // ,

power () . - , , . power (2. 0, 2.0) double, 2. 0 - 2. double, , int, , int:

double power(double x, int n); //

4.0 double power() int 4 , - . 3.0, 3,04 , 81.0, .

double int, . ,

, , . , - , , . , , ,

static_cast. :

= power (, static_cast<int>(power(2.0, 2)));

, . . , , , .

 

- , . . , , . . , .

, .

, .

 

8xn. , - .

// 29

#include <stdlib.h>

#include <time.h>

#include <math.h>

#include <iostream.h>

#include <iomanip.h>

void allocMemory(int m, int n, double **&matrix);





:


: 2016-11-18; !; : 639 |


:

:

.
==> ...

1676 - | 1621 -


© 2015-2024 lektsii.org - -

: 0.032 .