Examination_IT / ComputerScience_LaboratoryWork_ForStudent
.pdf211
void _tmain()
{
setlocale(LC_CTYPE, "Russian_Russia.1251"); using namespace std;
int nNumb; int *nDigital;
char szNameFile[_MAX_PATH] = "MyBiFile.bin";
//z L . unsigned long dwBytesPerSector;
//z . unsigned long dwSectorsPerCluster;
//z ! J . unsigned long dwNumberOfFreeClusters;
//! % !. __int64 nFreeSpace;
int i;
//I! € fi ! ! J I K L. ifstream fi;
//r J JL K L.
fi.open(szNameFile, ios::binary); if(!fi.is_open()) // v ;.
{
cout << "r; J K L "<< szNameFile << endl; system("pause");
return;
}
// | ! J I K L. fi.read((char*)&dwBytesPerSector, sizeof(DWORD)); fi.read((char*)&dwSectorsPerCluster, sizeof(DWORD)); fi.read((char*)&dwNumberOfFreeClusters, sizeof(DWORD)); fi.read((char*)&nNumb, sizeof(int));
//( J! % ! J . nDigital = new int[nNumb];
//| ! J
fi.read((char*)nDigital, nNumb*sizeof(int)); fi.close(); // I J K L.
//z ! ! L. nFreeSpace = __int64(dwNumberOfFreeClusters)*
dwSectorsPerCluster*dwBytesPerSector;
//R % % QI JL IJ. setlocale(LC_CTYPE, "Russian_Russia.1251");
cout << "( J, % J I K L: "; cout << szNameFile << endl << endl;
cout << "#:" << endl << "======" << endl;
212
for(i=0; i<nNumb; i++)
cout << nDigital[i] << " "; cout << endl << endl;
cout << "J ! C:" << endl << "==================" << endl;
cout << "s L .................. "; cout << dwBytesPerSector << endl;
cout << " ............. "; cout << dwSectorsPerCluster << endl;
cout << "z ! J .. "; cout << dwNumberOfFreeClusters << endl;
cout << "! %.......... " << nFreeSpace/1024;
cout << " Kb" << endl << endl;
// r 9! % J! L ! I. delete[] nDigital;
system("pause");
}
. , >,
>, -
.
Ei,- : +)+ , 641(. - ,j .+E( +3( (5 +E(34
D
, 17.1…17.4,
R .
- n >, AB
kp = pJ p p p p# #,
.
- 6(- 1 ,.(2- ,- ( FirstFile)
> n C
R
>.
= FirstFile -
AB A > A:
1)– (1 );
2)AB – > A (1
213
):
R>> (5 );
,
>- (2 );
mj,
> C -
.
= > A >
.( (3 VSC++. D
.( (3 > ,
R . 17.5.
H. 17.5. = > > Poli.txt
.( (3. 4 > A
FirsFile
= >, FirsFile
>, > >, -
. 17.3.
|
|
|
2 17.3 |
|
|
Q >. |
|
|
|
|
|
( |
|
|
$ |
Y |
|
||
|
|
|
|
0 |
n |
|
! > > ( ) |
|
f ' ' (1 Y) |
||
1 |
m |
|
! > |
|
x1, y1 |
|
! > |
|
x2, y2 |
|
! > |
|
… |
|
… |
|
xm, ym |
|
! m- > |
214
|
|
. . 17.3 |
|
|
|
|
|
( |
|
$ |
|
Y |
|||
|
|
||
|
f ' ' (2 Y) |
||
2 |
k |
! > |
|
|
x1, y1 |
! > |
|
|
x2, y2 |
! > |
|
|
… |
… |
|
|
xk, yk |
! k- > |
|
… … … |
|
|
|
|
f ' n- ' (n- Y) |
||
n |
l |
! n- > |
|
|
x1, y1 |
! n- > |
|
|
x2, y2 |
! n- > |
|
|
… |
… |
|
|
xl, yl |
! l- n- > |
! . 17.3, FirsFile -
A >- >. ! – B ( double), -
– . = > A >
B , .
3( (- 1 ,.(2- ,- ( TwoFile) - > >, [ -
> >, . 17.6.
D TwoFile -
> p, kp .-3/- 1 ,.(2- ,- ( ThirdFile)
, TwoFile, . H-
e A -
TwoFile.
- >
char.
; FirstFile 17.5.
ThirdFile 17.6.
215
H. 17.6. H TwoFile
.( (3
, 3, 0 17.5. #+5. FirstFile.cpp
void _tmain()
{
//z %. int n;
//z_KK J %. double k[5];
//( % I I K -%. double xmin, xmax;
//! .
int m;
double x; |
// |
. |
|
|
double x2, x3; // |
% x. |
|||
int i, j; |
// |
|
. |
|
double dx; |
// |
% e |
. |
|
double y; |
// |
I |
K |
. |
char szNameFileTxt[] = "Poli.txt"; char szNameFileBi[] = "MyFile.bin";
//k(v † % % QI JL IJ.
//k(v † I! € file ! ! J I
//K L szNameFileTxt J% %
//;.
//k(v † I! € fi ! I % ! J JL K L
//szNameFileBi.
216
//k(v † K % I
//K L.
//k(v † I % J JL K L K L-
//%.
//” % K L-%.
for(i=0; i<n; i++)
{
//” % _KK %. for(j=0; j<5; j++)
{
//k(v † _KK j i- % I
//K L (K : J k).
}
//k(v † J J xmin, xmax
//_ I K L.
//k(v † I % J JL K L .
//( J % % J. J%
//%.
dx = (xmax - xmin)/m; |
// % e . |
// ” % |
[xmin, xmax]. |
for(j=0; j<m+1; j++) |
|
{ |
|
//k! Q J e I x y
//I % J JL K L.
}
}
// k J K L J. file.close(); fi.close();
cout << " I ." << endl; system("pause");
}
, 3, 0 17.6. #+5. ThirdFile.cpp
void _tmain()
{
int |
n; |
// |
|
%. |
int |
m; |
// |
|
! . |
int i, j; double y;
double x, xmin, xmax, ymin, ymax;
char szNameFileTxt[] = "Polinoms.txt"; char szNameFileBi[] = "MyFile.bin";
// R % % QI JL IJ.
217
setlocale(LC_CTYPE, ".1251");
//k(v † I! € fi ! ! J I
//K L szNameFileBi J% %
//;.
//k(v † I! € file ! I % ! J JL
//K L szNameFileTxt.
//k(v † ! J I K L
//K L-%.
//k(v † % ; JL K L K :
//K L-%.
//” % K L-%.
for(i=0; i<n; i++)
{
file << "~ -% " << "." << i+1 << endl;
//k(v † I K L K :
//I ! K :
//% L (xmin, y).
// k(v † %, ymax=ymin.
//” % I ! ! % I. for(j=1; j<m; j++) // ! J .
{
//š(v † K : ! j-L
//k(v † J e I ymin ymax.
}
//k(v † ! J % ! L (xmax, y).
//k(v † J e I ymin ymax.
//k(v † J ! JL K L L! : K :.
//k ! Q I L K .
file << "k ! Q I L : "<< endl; file << scientific << setprecision(12);
file << "OQ I L K : " << endl; file << "# Q I K : "
<< endl << endl; cout << endl;
cout << fixed;
}
// k J K L J. file.close(); fi.close();
cout << " I ." << endl; system("pause");
}
218
e , > ThirdFile.cpp
, B R >-
- , . - R -
A >- A, A . 17.7.
H. 17.7. . >, R
ThirdFile
|
|
2 |
|
|
||
|
|
|
||||
|
|
|||||
|
Mathcad - |
|||||
|
|
|
- |
|||
|
C |
. |
P |
|||
|
. 17.8 |
|
||||
|
> >, - |
|||||
|
R>> |
|
|
|||
|
- |
|||||
|
|
> |
|
Poli.txt |
||
|
( . 17.5). |
|
|
|
|
|
|
|
! |
|
|
||
|
. 17.8, |
|
|
|||
|
|
|
|
|||
|
Mathcad - |
|||||
|
C - |
|||||
|
||||||
H. 17.8. ` >- |
( . 17.7), |
- |
||||
( . 17.5) , |
R |
|
219
[ . . -
– C -
.
17.3.+ ,+ 34 )+*+ ,5
% |
: |
; |
|
||
1 |
1 |
P FirstFile |
|
|
ThirdFile |
2 |
2 |
P FirstFile |
|
|
TwoFile |
3 |
3 |
P FirstFile, Two- |
|
|
File ThirdFile |
17.4.( *( 641(. - , +E(34
1.; B A .( (3 >,
B n .
2.; , AB -
>-
>, AB A A >- -
AB A >. D-
, B >,
.
3.; , AB -
>- -
>. D , -
B >- ,
. . > -
> . - -
220
.
4.- , A . 3,
.
5.; -
.
6. .> .
7.R .
17.5.-E(6+ , (*- 2+ ,j (3D-3+
. :
1)> ;
2);
3)> cpp h;
4),
Mathcad.
( 3 (./ 4- 6(1 ( 4
1.! > >?
2.! > >?
3.! ofstream, ifstream fstream?
4.D (>) ofstream, ifstream.
5.P C , AB >
int.
6.P C , AB >
double.
7.P C AB > -