_____________ ..
_________________2011 .
..
9
C++
220000 ,
220700 .
519.6
00000
00
..
00 C++. I , 220000 , 220700 / .. . : - , 2011. 11 .
519.6
00000
1 2011 .
.
______________ ..
-
______________ ..
..
, 2011
.., 2011
.
, 2011
9
C++
. ++, Borland C++.
C++ , . , , .
Struct _
{
_1 _1;
_2 _2;
_k _k;
};
1. .
struct Worker { // 4 :
char fio[30]; // fio
int date, code; // date code int
float salary; // salary float
};
__ _ ë, _ û;
(.).
, Worker number1; :
number1.fio, number1.date, number1.code, number1.salary, , C ++ , , :
cin >> number1.fio; number1.date = 1985;
|
|
if(number1.code == 11) number1.salary += 5000.33;
C ++ , :
struct A {int aA; float bA;}; // A
// : aA bA,
struct B{A fB; char chB[20];}; // fB
// ,
B x[10]; // x
// 10 B.
x[0].fB.aA = 2; //
// fB .
x[1].chB[1] = q; //
//chB .
, , .
, :
. .
. .
C++ .
. , .
1.
struct Point { int x,y;};
Point GetCursorPosition()
{
Point cursor;
return cursor;
}
Point, x y .
2.
void DisplayCursorInfo()
{
Point cursor;
cursor = GetCursorPosition();
cout << cursor.x;
cout << cursor.y;
}
.
, :
3.
struct Box3
{
bool visible;
double x_center, y_center, z_center;
double x_size, y_size, z_size;
};
vec3 :
4.
struct box {
bool visible;
vec3 center;
vec3 size;
};
, . :
5.
void Display(const Box3& box) {
if (box.visible) {
cout << Center: ( << box.center.x << , <<
box.center.y << , <<
box.center.z << ) << endl;
}
}
, . ( == != ). .
, .
6. , m ´ n .
sum_abs_in_rows, Massiv_2, Massiv_1.
#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
|
|
#include <conio.h>
const int nElem = 20;
struct Massiv_2{int Rows, Cols; float ar2[nElem][nElem];};
struct Massiv_1{int Cols; float ar1[nElem];};
// :
Massiv_2 init (int m, int n); // ;
void out2 (Massiv_2 mas2); // ;
float absF (float x) { return x < 0? -x: x;} /* ; */
Massiv_1 sum_abs_in_rows (Massiv_2 mas2); /* ; */
void out1(Massiv_1 mas1); // .
void main(void)
{ clrscr();
randomize();
int M, N;
cout<<"Rows "<<"(<="<<nElem<<"): ";cin>>M;
cout<<"Cols "<<"(<="<<nElem<<"): ";cin>>N;
// :
Massiv_2 m2= init(M,N);
// :
out2(m2);
//
// :
Massiv_1 m1 =sum_abs_in_rows(m2);
// :
out1(m1);
getch();
}
// .
Massiv_2 init(int m, int n)
{Massiv_2 mas2; mas2.Rows = m; mas2.Cols = n;
for(int i = 0; i < m; i++)
for(int j = 0; j < n; j++)
mas2.ar2[i] [j] = (float)(random(30) - 15) / 10;
return mas2;
}
void out2(Massiv_2 mas2)
{for(int i = 0; i < mas2.Rows; i++)
{for(int j = 0; j < mas2.Cols; j++)
cout << setprecision(2) << setw(5) << mas2.ar2[i] [j];
cout<<"\n";
}
}
Massiv_1 sum_abs_in_rows(Massiv_2 mas2)
{ Massiv_1 mas1;
float S;
mas1.Cols = mas2.Rows;
for(int i = 0; i<mas1.Cols; i++) mas1.ar1[i] = 0;
int k = -1;
for(int i = 0; i<mas2.Rows; i++)
{ S=0; ++k;
for(int j=0; j < mas2.Cols; j++) mas1.ar1[k] += absF(mas2.ar2[i] [j]);
}
return mas1;
}
void out1(Massiv_1 mas1)
{cout<<"\n";
for(int i = 0; i < mas1.Cols; i++)
cout << setprecision(2) << setw(5) << mas1.ar1[i]; }
:
. , .
7.
struct Line {
vec3 pt1, pt2;
double length;
};
length pt1 pt2. length . : . length.
9
.
1. .
2. .
3. .
4. .
5. .
6. .
7. ,
8. , [Min; Max], ; Min , Max .
9. .
|
|
10. , .
11. , [a, b], .
12. , [a, b ], .
13. , [a, b].
14. .
15. , .
;
;
;
-;
;
.
1. . . ++. . .: .: , 2001. 241 .
2. .. /++. . .: , 2010.
3. . ++. . .: , 2003. 645 .
++
I , 220000 ,
220700 .