.


:




:

































 

 

 

 


9.9 n .




Int mean (int *iPtr, int n)

{ int index;

long sum;

if (n>0)

{ for (index=0, sum=0; index<n; index++)

sum+=*(iPtr+index);

return sum/n; // sum / n

}

else

{ cout<< <<endl;

return 0;

}

}

, . , .

Int iarray [10];

int *iPtr = iarray; // , iPtr=&iarray[0].

++ . , 3, ( &array[3]). , , , , .

void , .

, . : iarray[3]=10; *(iarray+3)=10;

++ , . , . : () .

&.

9.10.

# include <iostream.h>

int value=10;

int &refval=value; // value

int main (void)

{ cout<<value=<<value<<endl;

refval+=5; //

cout<<value=<<value<<endl;

cout<< value <<&value<<endl;

cout<< refval <<&refval<<endl;

return 0;

}

, . , , , . , , &. -.

9.11.

# includ <iostream.h>

void Inc_val (int i) // -

{ i++; //

}

void Inc_ptr (int *i) //

{(*i)++; //

}

void Inc_ref (int & i) // -

{i++; // !

}

int main(void)

{ int j=10;

cout<<j=<<j<<endl;

Inc_val (j);

cout<< Inc_val (j) j = <<j<<endl;

Inc_ptr (&j);

Cout<< Inc_ptr (j) j=<<j<<endl;

Inc_ref (j);

Cout<< Inc_ref (j) j=<<j<<endl;

return 0;

}

, , . , . :

1) (&);

2) (*).

, . .

9.12. .

#include <iostream.h>

const int arraySize = 0xF;

static int valArray[arraySize];

int &valueAt(int indx)

{ return valArray [indx];

}

int main (void)

{ for (int I=0; I<arraySize; I++)

valueAt (i)=1<<I;

for (I=0; I<arraySize; I++)

cout<<<<I<<=<<valueAt(i)<<endl;

return 0;

}

valueAt(int) , .

7. ?

2. ? ? ?

3. ?

4. ? ?

5. ?

6. return? ?

7. , :

hallo (num)

{ int num, count;

for (count =1; count <= num; num++)

cout<<Hello, my friend!<<endl;

}

1, 21 = {ai| i = 0,1,,7}, B = {bjj = 0,1,,5}, C = {ck k = 0,1,,9}, D = {dnn = 0,1,,9}

 

2, 22 = {aj| i = 0, 1,, 8}, B = {bjj = 0, 1,,5}, C = {ck k = 0,1,,6}
3, 23   = {mi i = 0, 1,,7}, L = {ljj = 0, 1,,6}, C = {ck k = 0, 1,,8}
4, 24 = {ai i = 0, 1,, 6}, B = {bjj = 0, 1, 2, 3}, C = {ck k = 0, 1, 2,, 10}
5, 25 = {aij}, B = {bij}, i = 0, 1, 2, 3; j = 0, 1, 2,, 6 D, .
6, 26 A = {ai} B = {bi}, i = 0, 1, 2,,9 X = {xi} Y = {yi} :
7, 27 M = {mij} N = {nij}, i = 0, 1, 2,, 7; j = 0, 1, 2,, 5 D, M N .
8, 28 = {ij} Q = {qij}, i = 0, 1, 2,, 6; j = 0, 1, 2,, 4 B R, A Q .
9, 29 P = {pij} Q = {qij}, i = 0, 1, 2,, 4; j = 0, 1, 2,, 7 R T P Q .
10, 30 = {ij} D = {dij}, i = 0, 1, 2,, 5; j = 0, 1, 2,, 5 X Y C D .
  W = {wij} Z = {zij}, i = 0, 1, 2; j = 0, 1, 2,, 7 T S W Z, .

 

 

  B = {bij} D = {dij}, i = 0, 1, 2,...,7; j = 0, 1, 2, 3, Y Z, B D, R.
  = {ij}, Q = {qij}, i = 0, 1, 2,..., 5; j = 0, 1, 2,..., 8 R T, P Q .
  A = {aij}, B = {bij}, i = 0, 1, 2,..., 5; j = 0, 1, 2, 3 X = {xij}, Y = {yij} :
  A = {ai}, B = {bi}, C = {ci}, i = 0, 1, 2,...,6
  A = {aij}, B = {bij}, i = 0, 1; j = 0, 1, 2 Y = {yij}, Z = {zij}
  = {i} D = {di}, i = 0, 1, 2,..., 6 S = {si} T = {ti}, i = 0, 1, 2,..., 6, :
  X = {xi| i = 0, 1, 2,..., 5}, Y = {yj| j = 0, 1, 2,..., 7}, Z = {zk| k = 0, 1, 2,..., 9},
  5- , .
  = {ij}, B = {bij}, i = 0, 1, 2, 3, 4 j = 0, 1, 2, 3 S=x0/x4+ x1/x3 +... +x4/x0, T= y0/y4+ y1/y3+... + y4/y0, xi, yi - i- .

 





:


: 2017-03-18; !; : 610 |


:

:

, , . , .
==> ...

801 - | 734 -


© 2015-2024 lektsii.org - -

: 0.016 .