Вы находитесь на странице: 1из 56

# ()

CIM

2003

()

CIM

2003

.

CIM,
.

: ,
..
: , ..

2003

1

:

F X.
. dX.

2
ax + b

x a
F =
x c
x

x < 0 b 0
x > 0 b = 0

a, b, c
F ,
( ) ( )
, .
,
a, b, c, .
a, b, c, ., ., dX
.
:
/*

<stdio.h> - /
<math.h> - floor() pow()
double floor(double x) -

.
double pow(double x, double y) -
x y.
*/
#include <stdio.h>

#include <math.h>
int main(int argc, char* argv[])
{
/* */
float
a, b, c;
float
StartX, EndX, dX;
float
F;
/* ,
*/
printf(":");
printf("\ta = "); scanf("%f", &a);
printf("\tb = "); scanf("%f", &b);
printf("\tc = "); scanf("%f", &c);
printf("\tX . = "); scanf("%f", &StartX);
printf("\tX . = "); scanf("%f", &EndX);
printf("\tdX = "); scanf("%f", &dX);
/*
dX */
for (float x = StartX; x <= EndX; x += dX)
{
/* F,
*/
if (x < 0 && b != 0)
F = a * (float)pow(x, 2) + b;
else if (x > 0 && b == 0)
F = (x - a) / (x - c);
else
F = x / c;
/* (( ) (
))
F .
<long>
*/
if (!(((long)floor(a) | (long)floor(b)) &
((long)floor(a) | (long)floor(c))))
/* () */
printf("x = %.2f\tF = %.0f\n", x, F);
else
/* */
printf("x = %.2f\tF = %.2f\n", x, F);

}
return 0;

/* */

:
:

x
x
x
x
x
x
x
x
x
x
x
x
x
x

=
=
=
=
=
=
=
=
=
=
=
=
=
=

-4.00
-3.50
-3.00
-2.50
-2.00
-1.50
-1.00
-0.50
0.00
0.50
1.00
1.50
2.00
2.50

a = 3.5
b = 8
c = 293
X . = -4
X . = 2.5
dX = 0.5
F = 64.00
F = 50.88
F = 39.50
F = 29.88
F = 22.00
F = 15.88
F = 11.50
F = 8.88
F = 0.00
F = 0.00
F = 0.00
F = 0.01
F = 0.01
F = 0.01

:
1

F . . dX.
ax + b
< 0 b = 0

x a

x c
F=
> 0 b = 0

, b,
- .

F ,
( ) ( )
, . ,
, b, ,
- . , b, , ., ., d
.
2

F . . dX.
1

b + 5 < 0 = 0

ax

x a
F=
+ 5 > 0 0
x

10 x

c 4
, b,
- .

F ,

( ) ( ) ,

. ,
, , , . , , , ., ., d
.

3

F . . d.
ax + bx + c
a < 0 c 0

a > 0 b = 0
x c

a(x
+ c)

F=

a,b,c - .
,
( ) ,
. ,
, b, , . a, b, , ., ., d
.
4

F . . d.
ax - c
c < 0 x 0

x a
F=
c > 0 x = 0

c
bx

c a

,b,
- .

F ,

. ,
, b, , . a, b, , ., ., d
.

5

F . . d.

a < 0 b 0

10 + b

x
a
F=
> 0 b = 0
x c

2
3x
+

, b,
- .

F

,
( ) ,
. ,
, b, , . , b, , ., ., d
.
6

F . . dX.

ax + b x + c
c < 0 b 0

x +a
F = c > 0 b = 0
x +c

c
, b,
- .

F ,

( ) ( ) ,
2

. ,
, b, ,
- . , b, , ., ., dX
.

7

F . . dX.
- ax2 - b
< 5 0
x a
F=
> 5 = 0
x
x

c
, b, -
F ,
( ) 2 ( ) ,
. , a, b, , , 2
( 2) - . , b, , .,
., dX .
8

F . . d.
- ax2
< 0 b 0
a x
F=
> 0 b = 0
cx
x

c
, b, - .
F ,
( 2 ) ( ) ,
. ,
, b, , ,
2 ( 2) - . , b, ,
., ., .

9

F . . d.
ax2 + b2x
a < 0 x 0
x a
F=
x a > 0 x = 0
x c
x
1+

c
, b, - .
F ,
( ) ( ) ,
. , , b, , , . , b, , ., ., d
.
10

F . . dX.

F=

ax2 bx + c
x a
x c
x
c

< 3 b 0
> 3 b = 0

, b, - .
F ,
( ) ( 2 ) ,
. , , b, , , ,

2 ( 2) - . , b, ,
., ., d .
11

F . . d.
ax2 +
F=

x a
( x c) 2

x2
c2

< 1 c 0
> 1,5 c = 0

, b, - .
F ,
( ) 2 ,
. ,
, b, , 2 (
2) - . , b , ., ., dX
.
12

F . . d.
ax2 + b2 + c
F=

x a
x c
x
c
+
c
a

< 0,6 b + c 0
> 0,6 b + c = 0

, b, - .

10

F ,
( ) ,
. ,
, b, , . , b, , ., ., d
.
13

F . . dX.

F=

ax2 + b
x a
x
x
c

x - 1 < 0 b - x 0
1 > 0 b+x = 0

a, b, - .
F ,
( ) 2 ( )
, . ,
, , , ,
2 ( 2) - .
a, b, , ., ., d .
14

F . . d.

11

F=

- ax2 - b
x a
x
x

+
c
x

x + c < 0 a 0
+ c > 0 a = 0

, b, - .
F ,
-( 2 ) ( 2 )
, . ,
, b, ,
2 ( 2) - . , b, ,
., ., d .
15

F . . d.

F=

- ax2 + b
x
+ 5,5
x
x
c

x < 0 b 0
> 0 b = 0

, b, - .
F ,
( ) ,
. ,
, b, , . , b, , ., ., d
.

12

16

F . . .
a(x + c)2 - b
x < 0 b 0
x a
F=
> 0 b = 0

x
a+

c
,b, - .
F ,
( 2 ) ( ) ,
. ,
, b, , ,.,
2 ( 2) - . , b,
, ., ., dX .
17

F . . d.

F=

ax2 cx + b
x a
x
x
a c

x + 10 < 0 b 0
+ 10 > 0 b = 0

, b, - .
F ,
( ) ( )
, .

13

, , b, ,
, - . a, b, ,
., ., dX .
18

F . . dX.

ax3 + bx2
F=

x a
x
x +5
c( x 10 )

x < 0 b 0
> 0 b = 0

, b, - .
F ,
( ) ,
. ,
, b, , - .
, b, , ., ., d .
19
(
F . . dX.

14

F=

a(x + 7)2 - b
x d
ax
x
c

x < 5 b 0
> 5 b = 0

, b, , d, - .
F ,
( 2 ) ( 2 )
, . ,
, b, ,
2 ( 2) - . , b, ,
., ., ., d .
20

F . . d.
2x c
cx a
x a
x c
x
c
+
c
2x

F=

x < 0 b 0
> 0 b = 0

a, b, - .
F ,
( ) ( )
, . ,
, b, , ,

15

- . , b, , ., ., d
.

16

2

:

,
, :
1)

;
2)

,

.
.

:
.
:
/*
:
<stdio.h> - /
*/
#include <stdio.h>
int main(int argc, char* argv[])
{
/* ,
*/
const
MAX_ELEMENTS = 8;
/* */
float
m[MAX_ELEMENTS];
float
sum = 0;
float
result = 1;
int
iMax, iMin;
/* */
for (int i = 0; i < MAX_ELEMENTS; i++)
{
printf("m[%d] = ", i);
scanf("%f", &m[i]);
}

17

/*
0 */
iMin = iMax = 0;
for (i = 0; i < MAX_ELEMENTS; i++)
{
/*
*/
if (m[i] < 0) sum += m[i];
/*
*/
if (m[i] > m[iMax]) iMax = i;
if (m[i] < m[iMin]) iMin = i;
}
/* ,

*/
for (i = ((iMax < iMin) ? iMax : iMin);
i <= ((iMax > iMin) ? iMax : iMin);
result *= m[i++]);
/* */
printf("\n = %.2f\n",
sum);
printf(" = %.2f\n\n", result);
/* */
for (i = 0; i < MAX_ELEMENTS; i++)
{
for (int j = i + 1; j < MAX_ELEMENTS; j++)
{
if (m[i] > m[j])
{
result = m[i];
m[i] = m[j];
m[j] = result;
}
}
}
/*
*/
printf(" :\n");

18

## for (i = 0; i < MAX_ELEMENTS; printf("%.2f ", m[i+

+]));
return 0;
}

:
m[0]
m[1]
m[2]
m[3]
m[4]
m[5]
m[6]
m[7]

=
=
=
=
=
=
=
=

3
7
-4
8
-1
9
0
7

= -5.00
= 288.00
:
-4.00 -1.00 0.00 3.00 7.00 7.00 8.00 9.00

:
1
,
, :
1) ;
2) ,
.
.
2
,
, :
1) ;
2) ,

.
.

19

3
, ,
:
1) ;
2) ,
.
,
, -
(, 0, ).
4
,
, :
1) ;
2) ,
.
, ,
1.
.
5
, ,
:
1) ;
2) ,
.
, ,
[,b].
.
6
,
, :
1) ;
2) ,
.

20

,
, , -
.
7
, ,
:
1) ;
2) ,
.
,
,
, -,
.
8
,
, :
1) ;
2) ,
.
,
, 1,
- .
9
,
, :
1) ;
2) ,
.
, ,
, .
10

21

, ,
:
1) ;
2) ,
, .
,
,
, - ,
.
11
,
, :
1) ;
2) ,
.
, ,
[,b].
.
12
,
, :
1) ;
2) ,
.
,
,
[,b], - .
13
,
, :
1) ,
;
2)

22

.

.
14
,
, :
1) , 0;
2)

.

.
15
,
, :
1) , ;
2) ,
.
,
, -

(,

0,

).
16
,
, : 1)
;
2) ,
.

.
17
, ,
:
1) ;

23

2) ,
, .
,
,
1, - .
18
,
, :
1) , ;
2) ,
.
,
,
20%, - .
19
,
, :
1) ;
2) ,
.

.
20
,
, :
1) ;
2)

.
,
, , .

24

3

:

8 8
k, k-
k- .
,

.

:
#include <stdio.h>
int main(int argc, char* argv[])
{
/* 88 */
int
matrix[8][8] = {
{ 2, 7, 2, 7, 1, 4, 0, 3 },
{ 1, 0, 7, 6, 0, -8, 3, 5 },
{ 2, 7, 1, 8, 1, 4, 9, 3 },
{ 9, 2, 8, 5, 2, 0, 0, 6 },
{ 7, 1, 1, 3, 9, 3, 9, 1 },
{ 8, 2, 4, 9, 1, -6, 4, 9 },
{ 0, 3, 9, 0, 9, 4, 8, 8 },
{ 1, 8, 3, 2, 8, 2, 8, 0 }
};
int
i, j, iSumm; /*
*/
bool
bFlag;
/* */
/*----------------------------------------------*/
/*

*/
/*----------------------------------------------*/
printf("k = ");
for (i = 0; i < 8; i++)
{
/* */
bFlag = true;
for (j = 0; j < 8; j++)
{

25

/* i- j-
j- i- .

j
break */
if (matrix[i][j] != matrix[j][i])
{
bFlag = false;
break;
}
}
/*
*/
if (bFlag) printf("%d ", i);
}
/*----------------------------------------------*/
/*

*/
/*----------------------------------------------*/
printf("\n\n");
for (i = 0; i < 8; i++)
{
/* */
bFlag = false;
iSumm = 0;
for (j = 0; j < 8; j++)
{
/*

,
*/
if (matrix[i][j] < 0) bFlag = true;
/* i- */
iSumm += matrix[i][j];
}
/*

i- */
if (bFlag) printf(" #%d =
%d\n", i, iSumm);
}
return 0;
}

26

:
k = 2 6
#1 = 14
#5 = 31

:
1
. :
1) ,
;
2) ,
.
2
.
,
.

.
,
.
3
. :
1) ,
;
2) ,
.
4
. :
1) ,
;
2) ,
.

27

5
. :
1) ,
;
2) ,
.
6
. :
1) ,
;
2) .
:
ij, Aij
i- j-
.
7
8 8 k, k-
k- .
,
.
8

.
,
.
,
.
9
ij kl i-1
i+1, j-1 l j+1, (k, l) (i,j).
,

28

.

10 10.
,
.
10
,
.

10 10. ,
.
11

.
,
.
12
, ,
. ,
.
13

(
). n
.
14

N k
: 1-
, - ,

29

- , - ;
- .
15
.
,
.

.
,
.
16

.
,
.
17

,
, -
(2,2), - (3,3) . .,
.
,
.
18
. :
1) ,
;
2) ,
.
19
. :

30

1) ,
;
2) ,
.
20
. :
1) ,
;
2) .
:
A Aij ij
i- j-
.

31

1.
STUDENT,
:

Name ;

Group ;

Ses .
2. ,
:

Stud1, 10
Student;

Group;

,
,
4.

,
.

:
#include <stdio.h>
struct Student
{
char
Name[255];
int
Group;
float
Ses;
};

/* */
/* */
/* */

## int main(int argc, char* argv[])

{
/* */

32

const

MAX_STUDENTS = 5;
*/
Student Stud1[MAX_STUDENTS];
Student stTemp;
bool
is = false;

/*

/* */
for (int i = 0; i < MAX_STUDENTS; i++)
{
printf(" #%d:\n\t: ", i);
gets(Stud1[i].Name);
printf("\t: ");
scanf("%d", &Stud1[i].Group);
printf("\t: ");
scanf("%f", &Stud1[i].Ses);
}
/* Student Group
( ) */
for (i = 0; i < MAX_STUDENTS; i++)
{
for (int j = i + 1; j < MAX_STUDENTS; j++)
{
if (Stud1[i].Group > Stud1[j].Group)
{
stTemp = Stud1[i];
Stud1[i] = Stud1[j];
Stud1[j] = stTemp;
}
}
}
/* ,
4 */
for (i = 0; i < MAX_STUDENTS; i++)
{
if (Stud1[i].Ses > 4)
{
printf("\n%s #%d", Stud1[i].Name,
Stud1[i].Group);
/*
*/
is = true;
}

33

}
/* ,

*/
if (!is) printf("\n >
4 .");
return 0;
}

:
#0:
: Golodoniuc Pavel
: 12
: 8.77
#1:
: Vasia Pupkin
: 14
: 2.7
#2:
: Philip Lykov
: 11
: 6.8
#3:
: Alexander Pushkin
: 13
: 3.4
#4:
: Stepan Fedorov
: 11
: 4.8
Golodoniuc Pavel #12
Philip Lykov #11
Stepan Fedorov #11

1
1. STUDENT,
:
NAME - ;
GROUP - ;

34

SES - ( ).
2. , :

STUD1,
STUDENT;

GROUP;

, ,
4,0;

,
.
2
1. STUDENT,
:
N -
GROUP - ;
SES - ( ).
2. , :
STUD1,
STUDENT;
;

, 4 5;
,
.
3
1. STUDENT,
:
N - ;
GROU - ;
SS - ( ).
2. , :

35

STUD1,
STUDENT;
;

, 2;
,
.
4
1. RFL,
:
NAZN - ;
NUMR - ;
I - .
2. , :
AIRPORT,
RFL;
;
,
,
, ;

.
5
1. RLOT,
:
NAZN - ;
NUMR - ;
I - .
2. , :
IR,
RFL;

;

36

,
,
;
,
.
6
1. WORKER,
:
N - ;
S - ;
YR - .
2. , :
L,
WORKER;
.
,
,
;
,
.
7
1. RAIN,
:
NAZN - ;
NUMR - ;
I - .
2. , :
RAS,
RAIN;

;
,
;

37

,
.

8
1. RAIN,
:
NAZN - ;
NUMR - ;
I - .
2. , :
,
RAIN;
;
,
, ;
,
.
9
1. TRAIN,
:
BEGST - ;
TERM - ;
I - .
2. , :
RAS,
TRAIN;
;
,
;

,
.
10

38

1. TRAFIC,
:
GS - ;
R -
;
NUMER - .
2. , :
RAFIC,
RS;
;
,
;
,
.
11
1. MARSH,
:
5 - ;
R - ;
NUMER - .
2. , :
RFI,
RS;
;
,
,
;
,
.
12
1. N,
:
N - , ;

39

L - ;
DAY - ( ).
2. , :
BLOCKNO,
N;
;
,
;
,
.
13
1. N,
:
N - , ;
L - ;
DAY - ( ).
2. , :
BLOCKN,
N;
;
,
,
;
,
.
14
1. N,
:
NM - , ;
L - ;
DAY - (
).

40

2.

:
LN,
N;
;
,
;
,
.
15
1. ZN,
:
N - , ;
ZODIAC - ;
DAY - ( ).
2. , :
,
ZN;
;
,
;
,
.
16
1. ZN,
:
N - , ;
ZODIA - ;
DAY - ( ).
2. , :
,
ZN;
;

41

,
, ;
,
.
17
1. ZN,
:
N - , ;
ZODI - ;
DAY - ( ).
2. , :
,
ZN;
;
,
;
,
.
18
1. RI,
:
OVR - ;
G - , ;
STOI - .
2. :
SPISOK,
PRIC;
;
,
;

,

.

42

19
1. RI,
:
VR - ;
G - , ;
STOI - .
2. , :
SPISOK,
PRI;
;
,
, ;
,
.
20
1. ORDER,
:
L - ;
L - ;
SUMMA - .
2. , :
SPIS,
RDER;

;
,
, ;
,
.

43

5

:

,
.

.

.
:
8 8
k, k-
k- .
,

.
:
/*
:
<stdio.h> - /
*/
#include <stdio.h>
/* */
void Task1(int *mat, int m, int n);
void Task2(int *mat, int m, int n);
int main(int argc, char* argv[])
{
/*
int
matrix[8][8] = {
{ 2, 7, 2, 7,
{ 1, 0, 7, 6,
{ 2, 7, 1, 8,
{ 9, 2, 8, 5,
{ 7, 1, 1, 3,
{ 8, 2, 4, 9,
{ 0, 3, 9, 0,
{ 1, 8, 3, 2,
};

88 */
1,
0,
1,
2,
9,
1,
9,
8,

4, 0, 3 },
-8, 3, 5 },
4, 9, 3 },
0, 0, 6 },
3, 9, 1 },
-6, 4, 9 },
4, 8, 8 },
2, 8, 0 }

44

return 0;
}
void Task1(int *mat, int m, int n)
{
int
i, j;
/* */
bool
bFlag;
/ */
printf("k = ");
for (i = 0; i < m; i++)
{
/* */
bFlag = true;
for (j = 0; j < n; j++)
{
/* i- j-
j- i- .

j break
*/
if (mat[i * m + j] != mat[j * m + i])
{
bFlag = false;
break;
}
}
/*

/*
if
}
}

*/
*/
(bFlag) printf("%d ", i);

{
int
i, j, iSumm;
/*
*/
bool
bFlag;
/* */
printf("\n\n");

45

## for (i = 0; i < m; i++)

{
/* */
bFlag = false;
iSumm = 0;
for (j = 0; j < n; j++)
{
/*

,
*/
if (mat[i * m + j] < 0) bFlag = true;
/* i- */
iSumm += mat[i * m + j];
}
/*

i- */
if (bFlag) printf("Summ of elements of row #%d =
%d\n", i, iSumm);
}
}

:
k = 2 6
#1 = 14
#5 = 31

:
,
.

.
.

46

,
.
:
.
:
;
;
(, , );
,
,
, :
;

: )

40
,

, ;
) 30 ,
,
; )
25 , ,
;

.

.
:
#include <stdio.h>
#include <stdlib.h>

47

struct Form
{
int Age;
int Sex;
/* 0 - ; 1 */
int Education; /* 0 - ; 1 - ; 2
*/
int Question;
/* 0 - ; 1 */
};
int main(int argc, char* argv[])
{
int
Selection, i;
Form
*pForm = NULL;
int
RecCount = 0;
int
k1, k2, k3;
char
*str;
printf(" \n-------------------\n");
printf("1. \n");
printf("2. \n");
printf("3. \n");
printf("4. ");
while (true)
{
printf("\n\n : ");
scanf("%d ", &Selection);
switch (Selection)
{
case 1: /* */
pForm = (Form*)realloc(pForm, (RecCount + 1)
* sizeof(Form));
printf("\n :\n");
printf("\t: "); scanf("%d",
&pForm[RecCount].Age);
printf("\t (0 - ; 1 - ): ");
scanf("%d", &pForm[RecCount].Sex);
printf("\t (0 .; 1 .; 2
- ): ");
scanf("%d", &pForm[RecCount].Education);
printf("\t ? (0 - ; 1 - ): ");
scanf("%d", &pForm[RecCount].Question);

48

RecCount++;
break;
case 2: /* */
k1 = k2 = k3 = 0;
for (i = 0; i < RecCount; i++)
{
if (pForm[i].Sex == 0 &&
/* .*/
pForm[i].Age > 40 && /* 40 .*/
pForm[i].Education == 2 &&
/*
...*/
pForm[i].Question == 1) /*
.*/
k1++;
if (pForm[i].Sex == 1 &&
/* .*/
pForm[i].Age < 30 &&
/* 30
...*/
pForm[i].Education == 1 && /*
... */
pForm[i].Question == 0)
/*
. */
k2++;
if (pForm[i].Sex == 0 &&
/* ... */
pForm[i].Age < 25 && /* 25 .*/
pForm[i].Education == 0 &&
/*
... */
pForm[i].Question == 1)
/*
... */
k3++;
}
printf("\n #1: %d\n", k1);
printf(" #2: %d\n", k2);
printf(" #3: %d\n", k3);
break;
case 3: /* */
printf("\n :\n");
printf("====================================
================\n");
printf("

\n");
printf("====================================
================\n");
for (i = 0; i < RecCount; i++)
{
if (pForm[i].Education == 0)
str = "";

49

else if (pForm[i].Education == 1)
str = " ";
else
str = "
";
printf("%d
%s
%s
%s\n", pForm[i].Age,
((pForm[i].Sex) ? "" : "M"),
str,
((pForm[i].Question) ? "" :
""));
printf("________________________________
____________________\n");
}
break;
case 4: //
free(pForm);
exit(0);
break;
}
}
free(pForm);
return 0;
}

:

------------------1.
2.
3.
4.
: 1
:
: 48
(0 - ; 1 - ): 0
(0 .; 1 .; 2 - ): 2
? (0 - ; 1 - ): 1
: 1

50

:
: 41
(0 - ; 1 - ): 0
(0 .; 1 .; 2 - ): 2
? (0 - ; 1 - ): 1
: 1
:
: 25
(0 - ; 1 - ): 1
(0 .; 1 .; 2 - ): 1
? (0 - ; 1 - ): 0
: 1
:
: 18
(0 - ; 1 - ): 0
(0 .; 1 .; 2 - ): 0
? (0 - ; 1 - ): 1
: 1
:
: 16
(0 - ; 1 - ): 0
(0 .; 1 .; 2 - ): 0
? (0 - ; 1 - ): 1
: 1
:
: 27
(0 - ; 1 - ): 1
(0 .; 1 .; 2 - ): 1
? (0 - ; 1 - ): 0
: 1
:

51

: 17
(0 - ; 1 - ): 1
(0 .; 1 .; 2 - ): 1
? (0 - ; 1 - ): 0
: 2
#1: 2
#2: 3
#3: 2
: 3
:
====================================================

====================================================
48
M

____________________________________________________
41
M

____________________________________________________
25

____________________________________________________
18
M

____________________________________________________
16
M

____________________________________________________
27

____________________________________________________
17

____________________________________________________
: 4

:

.

52

1. 1_______________________1

2. 2_______________________18

3. 3_______________________26

4. 4_______________________33

5. 5_______________________45

6. 6_______________________48

53