. . i Z. . 10.13.
, , .
/++
[] ([ b1,..., bi,..., bn, *d1,..., *dj,..., *dm])
{
[return ;]
}
() ;
();
bi ;
dj , -
. 10.13.
, (*);
() ;
( ), ();
return ; ();
[ ] ;
{ } .
.
:
([a1,..., ai,..., an,c1,..., cj,..., cm])[;]
;
a1, ,ai, ,an (), ();
c1, , cj,, cm (), ();
() ;
[ ] .
:
[] ([ b1,..., bi,..., bn, *d1,..., *dj,..., *dm]);
() ;
();
bi ;
*dj , , (*);
() ;
[ ] ;
; .
:
, .. ai bi, cj dj, ;
|
|
;
;
, , , ;
;
, , , ;
return, return, .
return, ;
, return . void;
, , ;, ;
( ) , ;
, , *.
, .
.
! , . .
, , . 10.14, 10.15.
. 10.14. 1
1 ( ) ().
. 10.15. 2
2 ( ) , .
. ( ) .
( ) . , , .
. ( ), () . .
|
|
.
, , , ( ).
... main() { int j = 1, i = 1; ... printf("j=%d i=%d", j, i); func(j, &i); printf("j=%d i=%d", j, i); ... } void func(int j, int *pi) {... *pi = 0.5 * j + 1.; j = 2; ... } |
, j i. j pi. i j (i pi, j ). j i (j=1 i=1), (j=1 i=1.5). j , (i) . , j 1 ( ), i 2.
.
. 10.3.
10.3
n | m | i | j | xi | yj | SX | PX | SY | PY | d | k | z i | SZ | PZ | |
n | m | i | j | x[i] | y[j] | sx | px | sy | py | d | k | z[i] | sz | pz |
( 30 50 ) x z, , , y z.
, . . . , , :
sp(x, n, &sx, &px); sp(y, m, &sy, &py);
:
void sp(float *z, int k, float *sz, *pz)
. . , . return.
#include<stdio.h>/* -*/
#include<conio.h>/* getch(), clrscr()*/
#include<math.h> /* . */
#include <windows.h> /* CharToOem*/
void sp(float *z, int k, float *sz, float *pz);/* sp*/
main() /* */
{
float d, sx, px, sy, py, x[30], y[50]; /* */
int i, j, n, m; /* */
char buf[30];
clrscr();
CharToOem(" n, m: ",buf);
printf("\n %s ",buf);
scanf("%d%d", &n, &m);
printf("\n n=%d m=%d\n", n, m);
for(i = 0; i < n; i++)/* x[ i ] */
{
CharToOem(" x ",buf);
printf("\n %s (%d): ",buf,i+1);
scanf("%f", &x[i]);
}
for(i = 0; i < n; i++) /* x[ i ] */
printf(" %.2f",x[i]);
printf("\n"); /* */
for(j = 0; j < m; j++) /* y[ j ] */
|
|
{
CharToOem(" y ",buf);
printf("\n %s (%d): ",buf,j+1);
scanf("%f", &y[j]);
}
for(j = 0; j < m; j++) /* y[ j ] */
printf(" %.2f", y[j]);
sp(x, n, &sx, &px); /* */
sp(y, m, &sy, &py); /* */
d = (sx + sqrt(fabs(py))) / (log(px) - sy); /* d*/
printf("\n sx=%.2f px=%.2f sy=%.2f py=%.2f d=%.2f \n",
sx,px, sy, py, d);
getch();
}
void sp(float *z, int k, float *sz, float *pz)/* - sp*/
{
int i; /* i */
*sz = 0;
*pz = 1;
for(i = 0; i < k; i++) /* SZ PZ */
{
*sz = *sz + z[ i ];
*pz = *pz * z[ i ];
}
}
5 6 ;
1 1.6 1.8 15 23 ;
0.6 0.76 0.99 180 67.7 200 Y;
.
10.5.
. n, m (EditN, EditM). X Y (Edit, EditY).
sx, px, sy, py, d (EditSx, EditPx, EditSy, EditPy, EditD).
, . .
.
#include<stdio.h>/* -*/
#include<conio.h>/* getch(), clrscr()*/
#include<math.h>/* . */
void sp(float *z, int k, float *sz, float *pz);/* sp*/
void TSumprDlgClient::BNClickedOk()
{
// INSERT>> Your code here.
float d, sx, px, sy, py, x[30], y[50]; /* */
int i, j, n, m; /* */
char buf[30];
EditN->GetText(buf,10); /* */
n=atoi(buf); /* n*/
EditM->GetText(buf,10); /* */
m=atoi(buf); /* m*/
for(i = 0; i < n; i++) /* x[ i ] */
{
EditX->GetLine(buf, sizeof(buf),i);
x[i]=atof(buf);
}
for(j = 0; j < m; j++) /* y[ j ] */
{
EditY->GetLine(buf, sizeof(buf),j);
y[j]=atof(buf);
}
sp(x, n, &sx, &px); /* */
sp(y, m, &sy, &py); /* */
d = (sx + sqrt(fabs(py))) / (log(px) - sy); /* d*/
sprintf(buf,"%.2f ",sx); /* */
EditSx->SetText(buf); /* sx*/
sprintf(buf,"%.2f ", px); /* */
EditPx->SetText(buf); /* px*/
sprintf(buf,"%.2f ",sy); /* */
EditSy->SetText(buf); /* sy*/
sprintf(buf,"%.2f ", py); /* */
EditPy->SetText(buf); /* py*/
sprintf(buf,"%.2f",d); /* */
EditD->SetText(buf); /* d*/
}
/* sp */
void sp(float *z, int k, float *sz, float *pz)
{
int i; /* i */
*sz = 0;
*pz = 1;
for(i = 0; i < k; i++) /* SZ PZ */
{
*sz = *sz + z[ i ];
*pz = *pz * z[ i ];
}
}
5 6 ;
|
|
1 1.6 1.8 15 23 ;
0.6 0.76 0.99 180 67.7 200 Y;
.
10.6.
10.4.
. . , - . (10.4) .
A(m x n) B(t x s). .