
SPO5
.pdf31
/, 0 (A? 6 %:
int _tmain(int argc, _TCHAR* argv[])
{
POINT pt[10]; int n = 10;
// xfy z • !, P pt.
qsort((void*)pt, n, sizeof(pt[0]), ComparePtY);
}
z D !2 / 9 7 8 A /
{z, x, y}, 7% 8 ( ( /:
int ComparePtZXY(const void *arg1, const void *arg2)
{
POINT *pt1 = (POINT*)arg1; POINT *pt2 = (POINT*)arg2;
double z = pt1->z - |
pt2->z; |
|
if(z<0) |
return |
-1; |
else if(z>0) return |
1; |
|
double x = pt1->x - |
pt2->x; |
|
if(x<0) |
return |
-1; |
else if(x>0) return |
1; |
|
double y = pt1->y - |
pt2->y; |
|
if(y<0) |
return |
-1; |
else if(y>0) return |
1; |
return 0;
}
+ 9 ( 1 9 A 9 7% 8 6
(. 1% 9 %" " 9 06 0:
…
struct DItem
32
{
struct _finddata_t findData; DItem *prev, *next;
};
/////////////////////////////////////////////////////////////
//•c c " ~ Œ’|o•"–
//>! #= ƒ
DItem* CreateItem();
//f # #= ƒ # •
void Add(DItem *end, DItem *NewElem);
//’! ƒ
void Delete(DItem *end, DItem *NewElem); // "P = !
void FimdFile(char *Path, char *Mask);
//‚=# ! ! ƒ #
void PrintData(char *NameFile, struct _finddata_t *findData);
//‚=# ! ƒ
int Menu(void);
// = #
int CompareNameFile( const void *arg1, const void *arg2 ); int CompareSizeFile( const void *arg1, const void *arg2 ); int CompareDateFile( const void *arg1, const void *arg2 );
using |
namespace std; |
|
|
// % = = |
// |
#= ƒ |
|
DItem |
*g_Head = NULL; |
||
int g_SumFile = 0; |
// |
# ! =? # |
int _tmain(int argc, _TCHAR* argv[])
{
int i;
char File[] = "File.txt";
char FileSortName[] = "FileSortName.txt"; char FileSortSize[] = "FileSortSize.txt"; char FileSortDate[] = "FileSortDate.txt"; DItem *Curr, *Old;
struct _finddata_t *findData; char Path[] = "C:\\Windows\\"; char Mask[] = "*.bmp";
setlocale(LC_CTYPE, "Russian_Russia.1251");
// xfy z … ! ## ! ! =?
g_SumFile = 0; |
// |
! =? |
|
// |
# |
|
|
33 |
g_Head |
= CreateItem(); |
// >! # • ƒ |
|
|
// |
FimdFile(Path, Mask); |
// # = # |
|
|
|
// ! |
//f #=! ! #
findData = new _finddata_t[g_SumFile];
//xfy z … ! =# P ! …
//# ! #=! = # findData
//…. " # #
//findData.
//xfy z … ! ! P #g … = .
//‚=# ! ! ƒ #
PrintData(File, findData);
_getch();
do
{
// ‚=# ! ƒ
int NumbMenu = Menu(); switch(NumbMenu)
{
case 0: // > #
delete[] findData; return 0;
case 1:
qsort((void*)findData, g_SumFile, sizeof(findData[0]), CompareNameFile);
// ‚=# ! ! ƒ #
PrintData(FileSortName, findData); _getch();
break; case 2:
qsort((void*)findData, g_SumFile, sizeof(findData[0]), CompareSizeFile);
// ‚=# ! ! ƒ #
PrintData(FileSortSize, findData); _getch();
break; case 3:
qsort((void*)findData, g_SumFile, sizeof(findData[0]), CompareDateFile);
// ‚=# ! ! ƒ #
PrintData(FileSortDate, findData); _getch();
34
break;
}
} while(1);
_getch();
delete[] findData; return 0;
}
/////////////////////////////////////////////////////////
// Œ # #
int CompareNameFile( const void *a1, const void *a2 )
{
…
}
int CompareDateFile( const void *a1, const void *a2 )
{
…
}
int CompareSizeFile( const void *a1, const void *a2 )
{
…
}
/////////////////////////////////////////////////////////
// ‚=# ! ƒ
int Menu(void)
{
…
}
///////////////////////////////////////////////////
// ‚=# ! ! ƒ #
void PrintData(char *NameFile, struct _finddata_t *findData)
{
…
}
///////////////////////////////////////////////////
//>! #= ƒ # ># P >-
//•.
void FimdFile(char *Path, char *Mask)
{
…
}
///////////////////////////////////////////////////
//>! #= ƒ # ># P >-
//•.
35
//
DItem* CreateItem()
{
…
}
///////////////////////////////////////////////////
//
void Add(
DItem *end, |
// |
> |
|
#= ƒ |
DItem *NewElem |
// |
> |
|
#= ƒ |
) |
|
|
|
|
{
…
}
///////////////////////////////////////////////////
// ’! ƒ
void Delete(
DItem *end, |
// > |
! = |
|
DItem *NewElem |
// ƒ |
|
|
// > |
> P = |
||
) |
// ƒ |
|
|
|
|
|
{
…
}
3.3./ ?7 2 > ?
1.; 1 ! 9 / 0.
2.F ! 9 / 0.
3. .1 / % 0.
4. ./ 9 " 0 ! 0.
3.4. > 2 J 28 1
C " ! 6 ! 7 ( ( / /% 9 D- /0 %/ / D / D 9:
1.1 ! 6 0;
2.1% 9 0 ! 0 0 / ( , % - 6 6 :
2.2. ;
36
2.3.1 %;
2.4./ 1/ (;
2.5.! 8 0K " 02 ( 1
D 6 91 ().

37
4., .4 "2 21 24 - > ?12 3 4 2
4.1.( > ?
= 9A / 6 ! 6 ! 0 ( ( ( 1
% 0 7% 8 ( / 1! 0" ( 02 0 - D 6. * 91%( 1 (, %" 0 i 6 ! 6 !, D 0 9 6K 9 % ( ( . 10.1), 02 1 " 02 (10 -
(.
. 10.1. Calc
4.2. 21 1
. / 0" ( 0 0 D ( 1/ 9 ( /% -
9 ! " 0 D / D ? 9 " 0
! " 2 / 6 6 / . k 0 D D 2 9 (
! char ! / ( 91 .

38
4.2.1. "
0, 1% 0 , " D 1/ 9 / % 0: 8 " % 0.
8 " 0 %D 1 0, . / (
D % A / 7% 8 " 1 Š /0/%?
1 " (, – i ! 0" 6, -
7% 8 ( 010 !(.
! K 91% ( ( %-
/ ( 7% 8, %, ( (A? ( " 0, - % 6.
F , 0" 7 1 / ( /%A? %-
0 K:
. / 9 ( / / :
; % %A 7% 8 A 0" ( 7 D / -
9 /%A? ! 1:
double Factorial(int n)
{
double f;
if(n<0) return -1; // ƒ g
//# # > … • #=
//(#=? ! > ).
if(n==0 || n == 1) f = 1.0;
else
f = n*Factorial(n-1); return f;
}
C! 1 " ( 1 ? 7% 8 6 Factorial. 0! double (1 , " 91
8 " 02 K !0 2 / .
39
06 if(n==0 || n == 1) ! "
9 1 D 9 ( 0" ( 7 1! 0!,
1 K %. %" 2 /
, 8 9 6 ! (, 6 1- ? A ( 9 0 0 " 1 %A / A ( -
0 7% 8 6. 1% 9 ( 1! D 6 1 -
K 0.
0" 7 / 0 9- 1 ( 6 %. 1 D ( % (, /
7% 8 ( ! ? ( ! / , % 01 / % 6 7% 8 6 / D ( 01 6.
4.2.2. # $
' 9K ! " 2 0 D 6 D !0 9 1 D 0" %, 1 / 6 1 / ( 9 "
0 D 6. + 0" ( 0 A ( 7 % 6 'i % -F % :
0 D [{+|−} ]
D 9 [{×|/} D 9]
D 9 / [^ /]
/ {" | (0 D)}
(1 0 !2 / 9A / ( 8 6. F- 0 (A? ! " 0 D % %-
9. / 0 !, 7 % 'i % -F % , 1 " A
!(1 9 0 i 0 0 D (. m % 0 ! – 1 -
/ 9 02 , {+|−} 1 " + −.
0 «9», 9 1 / / ( (.
; /%A? 6 : |
|
|
2^2 11 × |
5 − 1 + 6 |
||
0 ( (A (: |
|
|
||||
D (: |
2^2 11 × 5, 1, 6 |
|||||
/ : |
2^2, |
11, |
5, |
1, |
6 |
|
|
2, |
2, |
11, |
5, |
1, |
6. |
40
z 1 9 ! D 0 D:
5 + 6 × 2 4 + 13 + 7 × 2 5 + 3^2,
0 % ( !%/% ( ( 9 (:
5 + 6 × 2 4 + 13 + 7 × 2 5 3^2
D ( :
5 + 6 × 2 4 + 13 + 7 × 2 5 5
/ D ( ( (A ( 0 D ( 1 A" 0
:
5 + 6 × 2 4 + 13 + 7 × 2
; 1 8 ( 6 1 / " 0 ( ( / %-
% , D/ K 0 (A ( 8 7 "-
8 % 0 (/-
(). / %" % ( ( ( ( 6 – 1! 0 D ( 91% ( / ( %" ( 1 " ( / .
.% 9 2 / 1 / ( 0 D:
5 × 4 − 345 + 55
F K - 1 i %" / D ! 9 6 2 (1 / 9 / ( 0 %).
1.0" ( «5 × 4» ?9A 7% 8 0- " (A? 6 1 / (.
2. . 0" 1 / ( %" 1 " -
/ «5» - K 6K %" i " 5.
3.2 !%/% " 9 ( 0 «×» «/» !%/
! 1 0 9 " A? ( /0 " . /
%" 0 «×», 1 «4». k 1 %- D 9 5 4 %" 9 1% 9 20. + /%A? -
( ( ( «−», 1! 1 / ( ? (. +-
9 ( 1 ! 9 /%A?%A " 9 :
− 345 + 55
4.C / ( 1 , (? 6 % – i 1 «−» 2 /
0/ A ?9A 7% 8 0"- ( 1 / (. .9 % / 9 6K 1!, " -