____________ ..
_________________2011 .
..
8
C++
220000 ,
220700 .
519.6
00000
00
..
00 C++. I , 220000 , 220700 / .. . : - , 2011. 12 .
519.6
00000
1 2011 .
.
_________________ ..
-
_________________ ..
..
, 2011
.., 2011
.
, 2011
8
C++
. C++, Borland C++.
, . . , , , <math.h>, . . , ( main). , , ;. , . , . .
:
< > < > (< >)
{
< >
}
:
< > < > (< >);
, return. return , . return, . , void ().
|
|
.
, . , :
float func (int x, int y, float z); // func
.
, , ,
void main () ;
clrscr () .
1. step, a b.
:
#include <iostream.h>
#include <conio.h>
float step (float a, int b)
{
int i; float p=1;
if (a < 0) return (-1);
for (i = 1; i <= b; i++) p*= a;
return p;
}
/* " -1 ", ab, .
*/
void main(void)
{
float x, rezult; int y;
cout <<" Vvedite osnovanie i pokasatel steneni: ";
cin>>x>>y;
rezult=step(x,y);
cout<<x<<"^"<<y<<" = "<<rezult;
getch();
}
:
-:
, , ,
rezult=step(3,5)<<endl;
cout:
cout << 3 ^ 5 = << step(3, 5) << endl;
, (. 1). , , .
2. swap, .
# include <iostream.h>
# include <conio.h>
void swap (int *a, int *b); // swap; *a,*b
void main (void)
{
int x = 5, y = 10;
cout<<"Do\n";
cout << "x=" << x << " y=" << y << endl;
swap (&x, &y); // swap
cout<<"Posle\n";
cout << "x="<< x << " y="<< y << endl;
getch();
}
void swap (int *a, int *b) // swap: a b
{
int x;
x = *a; *a = *b; *b = x;
}
:
, (&a, &b), * .
. , &, , &aa = a; ( ).
3. swap .
|
|
# include <iostream.h>
# include <conio.h>
void swap (int &a, int &b) //
{
int x;
x=a; a = b; b = x; // a b
}
void main (void)
{
int m = 10, n = 20, &x = m, &y = n; // x, y - m, n
swap (x, y); // m n
cout << " m = " << m << " n = " << n;
getch();}
:
, . , .
4. ci = ai + bi. .
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
void vvod_mas (int x[100], int n); /* vvod_mas
, 100 , n ; */
void rezultat (int x[100], int n) //
{
int i;
for (i = 0; i < n; i++)
cout << setw(5) << x [i];
}
void main(void)
{
int i, kol;
int a[100], b[ 100 ], c[100];
cout << Vvedite kolich elementov: ;
cin >> kol;
cout << Vvedite 1-y massiv: \n;
vvod_mas (a, kol); // <>
cout << \nVvedite 2-y massiv: \n;
vvod_mas(b, kol); // <b>
for (i = 0; i < kol; i++)
c[i] = a[i] + b[i];
cout << \nOtvet: \n;
rezultat(c, kol); // <c>
getch();}
void vvod_mas(int x [100], int n) //
{
int i;
for (i = 0; i < n; i++)
{
cout << Vvedite << i << element: ;
cin >> x[i];
}
}
:
8
1. S, T.
.
2. S, T.
, .
3. Y.
,
4. A, B, C.
.
5. S, T.
,
.
6. x, y, z.
.
7. S, T, A 0, , A 12.
,
8. A 0, A 6. x =1, 3, 4
,
9. m, n, 1,..., A n; B 1,..., B m; C 1,..., C 10.:
.
10. k, n, m, 1,...,Xk, Y1,...,Yn, Z1,...,Zm. :
t=max(y1, , yn)+max(z1, zm)+1+(max(x1, xk))2.
11. S,T.
H2(S,T) + MIN (H(S-T,T), H2(S-T, S+T), H(1,1)),
H(A,B)=
12. . , , .
13. x, y, z. , .
14. x, y, b. :
, .
15. x, y, z. :
s = f(2x, y) + f(x, z-5) + f(xy,3 z), .
;
;
;
-;
;
.
1. . . ++. . .: .: , 2001. 241 .
2. .. /++. . .: , 2010.
3. . ++. . .: , 2003. 645 .
|
|
++
I , 220000 ,
220700 .