.
++.
.
. ( main) , [ 13].
.
C++ , ( ) , .
. , . , , .
, .
( ). , , : , , , .
, , (, ). , .
:
([ _ ]);
- . , , int. void, , . , void* - . .
- , , .
_ - , . C++ . , . , , Void. (. .).
, , .
, , , .. , .
. , . , , return.
|
|
return - , . return , . . return .
, . . , . .
( void), , , , .
C++ , . :
- ;
- ;
- ;
- .
. , . .
. (-main) sum(), ( int). . , . - (. .4). - ( ). , ( sum()) ( main()) . :
#include<iostream.h>
int sum(int,int); // , ..
//
void main(void)
{int a,b,c,p; //
cin >> a >> b >> p; // a, b, p
c=sum(a,b); // sum()
//
cout << a b << c << endl; //
b=sum(p,c); // - sum()
cout << p c << b << endl;
}
//
int sum(int d, int l) //
{ //
int f;
f=d+l; //
return f;//
}
.4. - sum
. , .
|
|
#include<iostream.h>
sum(int,int,int*); //
void main()
{int a,b,c=0;
cin>>a>>b;
sum(a,b,&c); //
cout<<c<<endl;
}
void sum(intd,intl,int*f) //
{
*f=d+l // f c
}
. . :
#include<iostream.h>
sum(int,int,int&);
void main()
{
int a,b,c=0;
cin >> a >> b;
sum(a,b,c);
cout << c << endl;
}
//void
sum(int d,int l,int &f)
{
f=d+l; // f- c
}
. . :
#include <iostream.h>
int a,b,c;
sum(); //
main()
{
cin >> a >> b;
sum(); //
cout<<c<<endl;
}
sum() //
{c=a+b; //a,b,c-
}
. ++ 3.11 , . , , .
.
#include<iostream.h>
float ur(float x,float a=0.,float b=0.,float c=0.);
int main()
{float a=1.,b=2.,c=3.,x=0.5,y;
y=ur(x,a,b,c);
cout<<" "<<"\n";
cout<<y<<"\n";
y=ur(x,a,b);
cout<<" x,a b"<<"\n";
cout<<y<<"\n";
y=ur(x);
cout<<" x"<<"\n";
cout<<y<<"\n";
cin>>a;
}
float ur(float x,float a,float b,float c)
{
return a*x*x+b*x+c;}
.
4.25
x,a b
1.25
x
0.
C++ . , . . , 1- , . , . , , ( , ).
:
#include<iostream.h>
void quicksort(float* arr, int left,int right);
void main()
{const int n = 10;
float ar[n];
int i, l, r;
//cputs( );
for(i=0; i<n; i++){
cout<< [<<k<<] \n;
cin>>ar[i];
}
l = 0; r = n 1; //
quicksort(ar, l, n); //
for(i=0; i<n; i++)
printf(ar[ %d ]= %d \n, i, ar[i]); // cout<<ar[i]<< ;
}
void quicksort(float * arr, int left, int right)
{int i = left, j = right; //
float middle = arr[(left + right) / 2];
float temp;
while (i < j) {
while (arr[i] < middle) i++;
while (middle < arr[j]) j--;
|
|
if (i <= j) { //
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++;
j--;
}
}
if(i < right)quicksort(arr, i, right); /*
*/
if(left < j)quicksort(arr, left, j); /*
*/
}
quicksort(), : .
, :
- , ;
- ;
- ( , , , , ).
.
.
++, ( ).
.
5. :
:
1) ;
2) - ;
3) .
6. .
1.
F=
2.
Y= b b=0.5.
f() = 5x3 + sin2x,
3.
Z= a=2.5,b=4.8,c=4.2
y(x) = x5 * cos2(1/x).
4.
F(x,y)= x ; hx=0.25; y ; hy=1.25;
f(z) = 2 * *z.
5.
A= , a=5.62, c , hc=0.5,
f(x)=sin x2-5x+20lg(x).
6.
B= , a , ha=1, b=2.8, c=3.2,
f(x)=x3+3x2+arctg x.
7.
Zij=f(xi,yj), , x=(0.34;0.56;1;3),y=(0.76;0.12;2;4)
f(x,y)=cos(x2+1)sin2y.
8.
yi=f(ci)-f(b)-f(a), a=6.1; b=4.3; c=(6;7.6;9.5)
f(x)= .
9.
Zij=f(xi,yj), , x=(0.1;0.12;4), y=(3.2;8.39; 3),
f(x,y)=sin x2/3*e-y2.
10.
y =f(x1)+f(x2)*f(x3), x1=0.32; x2=8.5; x3=2;,
f(x)= .
11.
y =f(x1)*f(x2)/f(x3), x1=a2+5; x2=3.14; x3=0;,
f(x)= .
12.
y =f(x1)+f(x2)-f(x3), x1=ln(2.3); x2=cos(1.2); x3=1;,
f(x)= .
13.
y = , x1=2.6; x2=8.7; x3=0.1;,
f(x)=x3/2+6x2+tg(x).
14.
x=cos t2; y=cos t3; z=cos t4;
t ht=0.1.
15.
y=(f(2x1)-f(x1*x2))/f(x3), x1=3.3; x2=4.2; x3=5.6;,
f(x)=sin(x)/x +x sin(1/x).
16. , A[5][5], B[5][5], C[5][5].
17. i, x=t/ln(t), y=cos(t2/3), ti (t ht=0.1), .
18. i,
fj(x,cj)= e-(x-cj) *cos(x),
ti (c=(0.1; 0.3; 0.5; 0.9), x hx=0.1),
.
19.
x = , y = , z = ,
ti (t ; ht=0.1; a=4).
20.
yi=f(x1/5)*f(x2)-f(ci), x1=0.25; x2=6.5; c=(6;7.6;9.5),
f(x)= .
21.
F[5][5], G[5][5], S[5][5].
22.
y= , x1=2.6; x2=8.7; x3=0.1;,
|
|
f(x)=6x2+tg(x).
23.
Zij=f(xi,yj), , x=(0.1;0.5;4), y=(2.2;8.39; 3),
f(x,y)=tg x2*e-y2.
24.
Z=
y(x)=x2*tg2(1/x), a=1.5,b=3.5,c=2.2.
25.
y =f(x1)+f(x2)/f(x3), x1=0.25; x2=5.5; x3=2;,
f(x)= .
26.
R = f(n*m,k)+ f2(k,n)-f3(m,n), k= 3.6; m= 2.2; n = 5
f(a,b)=sin2(lg(ab))+
27. [3][3], B[5][5], D[6][6].
28.
D = P3(a[i][j], b[j][i]) (i, j), i [0; 4], j [0; 5],
P (k, h) = - 1.
29. [3][3], B[4][3], D[5][4].
30. N(11) M(11)
.
1. .
2. return.
3. C++?
4. .
5. C++?
.
:
1. . . []: / .. . - .: -, 2008; .: , 2008. - 352 .: . - ISBN 978-5-8199-0355-1: 157.41
2. . . [Text]: / ..; . . . ... - .: : -, 2009. - 416 .: . - ISBN 978-5-16-002690-9: 116.05
3. . . /++ [Text] / ... - .: , 2009. - 461 .: . - ISBN 978-5-94723-568-5: 176.99
5. , . . /++ [Text]: / .., ... - .: , 2007
6. . . [Text]: / .. , .. . - 3- ., . - .: , 2008. - 544 .: . - ISBN 978-5-06-004137-8: 633.93
7. , . /++ [Text] / . . - 2- ., . . - .: - , 2011. - 368 .: . . . (CD-ROM). - ISBN 978-5-94157-406-3: 233.26
8. .. . .( ) - : - , 2012.
9. .., .. . . . (, - ) - : - , 2008 60 .
10. .. . ( ) - : - , 2008.
:
1. . . []: / ... - 2- , . . - .: "", 2010. - 240 .: . - ISBN978-5-8199-0410-7: 175.01
2. , . . C++. [Text] / ... - C: , 2010. - 352 .: + 1 . . (CD-ROM). - ISBN 978-5-49807-102-2: 319.99
3. . . ++. [Text]: / .. , .. , .. ; . .. . - 2- ., . - .: -, 2000. - 344 .: . - ISBN 5-93517-014-0: 58.50, 69.30