++; .
. , , [ 9, 10].
.
, , . ().
() ++, , . . , . , , .. ( , ), , .. , .
(, , ), (, , )
0 , .
- , .. , ;
- .
- , . C : - void*; .
: . *, . :
int*p;
long a,*c;,
int* - int; p - ; c - (long*).
- &. long L;, - &L L.
long L,*a=&L,G,*p; // a L.
p=&G; // p G
0 - null. . : ; (, , ).
|
|
, , -&. , , . : ; ; , register.
- (*) , . . ,
int a,*p; // p - int
a=1;
.........
p=&a;
++*p; // *p=*p+1; a=a+1; (a=2)
.. - a .
, , -*, , .
. :
*p++; // *(p+1) (*p)++
++*p; // *p=*p+1
, - , - (arr1==&arr1[0]). , * . , i- - arr1[i] *(arr1+i), (arr1+i)==&arr1[i].
- , ,
V[1][2]=3;,
*(*(V+1)+2)=3; // *(V[1]+2)=3; V[1][2]=3.
, .. V[1]. (V) , , : (V+1). , .. 1 * (5 * sizeof(int)), , 5 int.
. (.. 2 * sizeof(int)), : *(*(V+1)+2).
, , .
- new;
- malloc ( ).
, . :
int n=10; // , ..
int *a = new int[n]; /* ,
, n int*/
double *b = (double *)malloc(n * sizeof (double));
|
|
/* n double malloc */
...
int n;
const int m=5;
cin>>n:
int **b = (int **) new int [n][m]; /* b , ((int **)) */
int (*a)[m] = new int [n][m]; /* a m int */
...
int n_str, n_stl;
cout<< - :;
cin>>n_str>>n_stl;
int **d = new int *[n_str];
for (int i=0; i<n_str; i++)
d[i] = new int [n_stl]; //
, .
- , delete[], :
delete [] a; // !
.
1. , .
. , . ( ) . . . - 1.
#include <iostream.h>
#include <iomanip.h>
void main(){
const int n_str=10, n_stl=20; // -
int a[n_str][n_stl];
int i, j;
cout<< :<<endl;
for(i=0; i<n_str; i++)
for(j=0; j<n_stl; j++) cin>>a[i][j];
for(i=0; i<n_str; i++){
for(j=0; j<n_stl; j++) cout<<setw(4)<<a[i][j]<< ;
cout<<endl; //
}
int kol_vo;
float S=0.;
for(i=0; i<n_str; i++){
kol_vo = 0;
for(j=0; j<n_stl; j++){
S+=a[i][j];
if (a[i][j] > 0) kol_vo++;
}
cout<<:<<i<<-:<<kol_vo<<endl;
}
S /= n_str * n_stl;
cout<< :<<S<<endl;
}
|
|
.2. - .
, . .
:
- , . . , , . , , . , .
- . , , . , .
|
|
. , , setw(), . <iomanip.h>. ( endl).
2.
#include<stdio.h>
void main()
{int V[ ][3]={1,2,3,
4,5,6,
7,8,9}
int i, s1, s2; s1=0; s2=0;
for (i=0;i<3;i++)
s1+=V[i][i]; //
for (i=0;i<3;i++)
s2+=*(*(V+i)+i); //
printf(s1=%d, s2=%d ,s1,s2);
}
.
++ .
, .
, ( ) . , .
5. :
:
1) - ;
2) ;
3) .
.
.
1. v[5][5].
2. X Y . , .
3. X[20]. Y, W.
4. ( v[5][5]).
5. 20 , , , .
6. ( v[5][5]) ( ), , .
7. ( ) 5x6 6x5 .
8. 4x6 .
9. ( ) 4x6 , . . ++.
10. ( ) 5x6 . ++.
11. V[4][5] .
12. V[4][5] .
13. V[23] .
14. V[23] . .
15. 4x6 .
16. V[23] , , .
17. V[23] .
18. ( ) V[4][5] , , .
|
|
19. ( ) 6x6 .
20. V[23] , , , , .
21. ( ) 8x8 .
22. V[4][4], .
23. () ( ) V[4][4] .
24. V[25] .
25. V[23] , .
26. G[15] H[10]. , .
27. V[4][4], .
28. ( ) 6x6 .
29. ( ).
30. B[6][6] .
.
1. ++?
2. ?
3. ?
4. ?
5. ?
6. ?
7. ?
8. ?
9. - -?
3.