.


:




:

































 

 

 

 


. X(n) ;




a = 0,96;

b = 35,

n £ 10;

m £ 15.

X(n) ;

xi i- ;

i;

i = i + 1 i.

n = 5, x1=4,5; x2=12,3; x3=-0,8; x4=17; x5=0,3

Y(m) ;

yj j- ;

j;

j = j + 1 j.

m = 4, y1=45,3; y2=-0,3; y3=12,7; y4=2,5

;

Y;

.

(X Y) (n m). , , . , , , X(n), Y(m). : , . k.

sum, :

sum(X, n), sum(Y, m).

X n, Y m.

, X(n) Y(m).

. 10.12.

. 10.12.

s i .

.

/++ .

, X(n), sum(x, n), Y(m) sum(y, m).

ü ! .

, , . . sum(&x[0], n) sum(&y[0], m).

, , .

.

, . , . .

, , (). .

. (), .

:

* 1 [, * 2,..., * N ];

, ;

* ;

1... N ;

, ;

[ ] ;

; .

() . ( ) .

,

float *a, *b;

int *f;

, a b, , f.

float x, y, *a, *b;

int *f, arr[10];

x, y arr. .

, ,

= &

;

& ;

.

,

float x, y, *a, *b;

b = &x;

b x.

 

f = &arr[0]; f = arr;

f arr ( ).

, .

(, ), .

(*) .

:

*

;

* .

ü ! , ( ). , , (/) .

,

float g, s, *t;

...

g = 15.3;

t = &g;

s = sqrt(*t) + *t + 0.5;

...

g, s t , t g, , t, s 15.3 ( g).

float x, z, *d;

...

d = &z;

*d = pow(x, 2) + 5;

...

( pow(x, 2) + 5) z d.

ü ! . ().

( ). ( ) . .

( ) .

,

... float funk(float *px, int n1); main() { float t, x[10]; ... n = 10; t = funk(x, n); ... }   float funk(float *px, int n1) {... for(i=0; i <= n1; i++) f =... + px[i] +....; ... return f; } ... float funk(float*, int); main() { float t, x[10]; ... n = 10; t = funk(x, n); ... }   float funk(float *px, int n1) {... for(i=0; i <= n1; i++) f =... + *(px+i) +....; ... return f; }

, . *.

i- :

;

.

( ), i . , .

.

, . 10.2:

10.2

a b n m i j xi yj z1 z2 z k ti s
a b n m i j x[i] y[j] z1 z2 z k t[i] s

#include<stdio.h>/* -*/

#include<conio.h/* getch(), clrscr()*/

#include <math.h> /* . */

#include<windows.h> /* CharToOem*/

float sum(float *t, int k);/* */

main() /* */

{

float a, b, z1, z2, z, x[10], y[15]; /* */

int i, j, n, m; /* */

char buf[30];

clrscr();

CharToOem(" a, b, n, m: ",buf);

printf("\n %s \n",buf);

scanf("%f%f%d%d", &a, &b, &n, &m);

printf("\n a=%.2f b=%.2f n=%d m=%d\n", a, b, n, m);

for(i = 0; i < n; i++) /* x[ i ] */

{

CharToOem(" ",buf);

printf("\n %s x(%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(" ",buf);

printf("\n %s y(%d): ",buf,j+1);

scanf("%f", &y[j]);

}

for(j = 0; j < m; j++) /* y[ j ] */

printf(" %f",y[j]);

z1 = cos(a) + sum(x, n); /* */

z2 = sum(y, m) - b; /* */

z = z1 / z2;

printf("\n\n z1=%.2f z2=%.2f z=%.2f\n", z1, z2, z);

getch();

}

/* */

float sum(float *t, int k) /* */

{

float s; /* */

int i; /* s i */

s = 0;

for(i = 0; i < k; i++) /* */

{

s = s + t[ i ];

}

return s; /* s */

}

0.96 35. 5 4

4.5 12.3 -0.8 17 0.3

45.3 -0.3 12.7 2.5

.

10.3.

. a, b, n, m (EditA, EditB, EditN, EditM). X Y (Edit, EditY).

z1, z2, z (EditZ1, EditZ2, EditZ).

, . .

.

#include <stdio.h>/* -*/

#include <math.h>/* . */

float sum(float *t, int k);/* */

void TSumprDlgClient::BNClickedOk()

{

// INSERT>> Your code here.

float a, b, z1, z2, z, x[10], y[15]; /* */

int i, j, n, m; /* */

char buf[30];

EditA->GetText(buf,10); /* */

a=atof(buf); /* */

EditN->GetText(buf,10); /* */

n=atoi(buf); /* n*/

EditM->GetText(buf,10); /* */

m=atoi(buf); /* m*/

EditB->GetText(buf,10); /* */

b=atoi(buf); /* b*/

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);

}

z1 = cos(a) + sum(x, n); /* */

z2 = sum(y, m) - b; /* */

z = z1 / z2;

sprintf(buf,"%.2f ",z1); /* */

EditZ1->SetText(buf); /* z1*/

sprintf(buf,"%.2f ", z2); /* */

EditZ2->SetText(buf); /* z2*/

sprintf(buf,"%.2f",z); /* */

EditZ->SetText(buf); /* z*/

}

float sum(float *t, int k) /* */

{

float s; /* */

int i; /* s i */

s = 0;

for(i = 0; i < k; i++) /* */

s = s + t[ i ];

return s; /* s */

}

0.96 35. 5 4

4.5 12.3 -0.8 17 0.3

45.3 -0.3 12.7 2.5

.

10.4.





:


: 2015-11-23; !; : 1049 |


:

:

- , - .
==> ...

1508 - | 1427 -


© 2015-2024 lektsii.org - -

: 0.054 .