.


:




:

































 

 

 

 





new delete.

, new , . NULL.

¼

double *x;

int i, n;

puts(" : ");

scanf(%d, &n);

x = new double [n];

if (x = = NULL) {

puts(" ! ");

return;

}

for (i=0; i<n; i++) //

scanf(%lf, &x[i]);

¼ //

delete [ ]x; //

¼

, , , .

...

int **m, n1, n2, i, j;

puts(" (, ): ");

scanf(%d%d, &n1, &n2);

m = new int*[n1]; // (n1=3)

for (i=0; i<n1; i++) //

*(m+i) = new int[n2];

for (i=0; i<n1; i++)

for (j=0; j<n2; j++)

m[i] [j] = i+j; // *(*(m+i)+j) = i+j;

...

for (i=0; i<n1; i++) //

delete []m[i];

delete []m;

...

 

 

, . . , , , .. .

.

.

, 2- 5-:

...

int sum(int a, int b, int c=0, int d=0, int e=0) { // 0

return (a+b+c+d+e);

}

int main ()

{

int x1=1, x2=2, x3=3, x4=4, x5=5;

int y2, 3, 4, 5;

2= Sum (1, 2); // ;

3= Sum (1, 2, 3); // ;

4= Sum (1, 2, 3, 4); // ;

5= Sum (1, 2, 3, 4, 5)

...

return 0;

}

:

1. .

2. , .

3. , .. x 1 + x 2 + x 3 + x 5 Sum ( 1, 2, 3, 5); .

Sum (x 1, x 2, x 3, 0, x 5);

++ , , , , , .

, .

, , .. .

, , :

1. , .

2. , .

3. , , .

S 1 , , , :

, S 1 ;

long, S 1 ;

, S 1 .

# include <stdio.h>

int S1 (int x, int y) {

return x+y;

}

long S1 (long x, long y) {

return x*y;

}

double S1 (double x, double y) {

return x/y;

}

int main ()

{

int a = 1, b = 2, c;

long i = 3, j = 4, k;

double x = 10, y = 2, z;

c=S1(a, b);

k=S1(i, j);

z=S1(x, y),

printf("\n c = %d; k = %ld; z = %lf. \n", c, k, z);

return 0;

}

:

c = 3; k = 12; z = 5.000000.

 





:


: 2016-11-12; !; : 501 |


:

:

: , .
==> ...

2255 - | 1881 -


© 2015-2024 lektsii.org - -

: 0.014 .