. .
6.050803 " ", 6.050903
ϲ
ȯ, ϲ
621.3.011 (075.8)
31.21173 94
[]: . . . . 6.50903 / : .. ҳ. .: ϲ, 2012. -42 .
ϲ
( _1_ _22_.__.2011)
. .
6.050903
-
: ҳ
³ | . . , .., . .. , . .., . |
-
̲ |
..... |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
C , , , 1972 г Bell Telephone Laboratories UNIX.
, ѳ , .
ѳ , , , . ѳ . C , C++, , ѳ, Java C#, ѳ .
ѳ . : , , ', , . , ѳ , .
, - . - C , . , '.
|
|
1
, . .
, . () () , ջ - . ѳ , .
ѳ :
Char , ;
Int , ;
Float ;
Double .
+, -, *, /, %. >, >=, <, <=.
pow(,) .
exp(x) .
printf() , . printf("rozvjazok 1 %f \n",y), rozvjazok 1 y, . \n , .
= - . , =5 , 5.
, . , , .
˳ , 䳿 .
#include <stdio.h>
int main()
{
float a = 3, b = 5, S;
S = a * b;
printf("s = %f", S);
return 0; }
, .
- , : "" - "" - .
if-else , . :
if (-)
else
-else
, , .
, , - . else, . else '.
- : , , .
. - :
|
|
:
#include <stdio.h>
#include <math.h>
Int main()
{
Float x, y;
x = 9;
if (x >= 0)
{
y = sqrt(x);
printf("y = %f", y);
}
Else
printf("x < 0");
Return 0;
}
. , ( ), . , .
1.1
x=1,426 y=-1,220 z=3,5 | ||
x=1,825 y=18,225 z=-3,298 | ||
x=0,335 y=0,025 | ||
a=-0,5 b=1,7 t=0,44 | ||
a=1,5 b=15,5 x=-2,9 | ||
a=16,5 b=3,4 x=0,61 | ||
a=0,7 b=0,05 x=0,5 | ||
a=1,1 b=0,004 x=0,2 | ||
m=2; c=-1 t=1,2; b=0,7 | ||
a=3,2 b=17,5 x=-4,8 | ||
a=10,2; b=9,2 x=2,2; c=0,5 | ||
a=0,3 b=0,9 x=0,61 | ||
a=0,5 b=3,1 x=1,4 | ||
a=0,5 b=2,9 x=0,3 | ||
m=0,7; x=1,7 a=0,5; b=1; c=2,1 |
. 1.2 ( ). , .
.
1.2
a=-0,5 b=2 | |||
a=1,5 | |||
a=2,8 b=-0,3 c=4 | |||
a=1,65 | |||
a=2,3 | |||
a=2,5 | |||
b=1,5 | |||
- | |||
a=20,3 | |||
*** (ln3(x) + x2 ) | t=2,2 | ||
a=2,6 b=-0,39 | |||
a=0,9 | |||
a=2,1 b=1,8 c=-20,5 | |||
a=0,3 n=10 | |||
a=2,5 b=0,4 |
1. ?
2. .
3. ? ?
4. , , sin(x), cos(x), ln(x), │x│.
5. : ) ` ; ) ` , sin(y); ) ` ?
6. . ?
7. ()=(((5+4)+3)+1)+0.
8. .
9. , . , ? , ?
10. ?
11. 䳿, .
12. 䳿 ?
13. , ? : ) 2 ; ) 3 ?
14. z=0, x<-2; z=1, -2≤x≤2; z=-1, x>2/
15. ?
2
|
|
, . .
, (). . , , , ( , ). , , .
- , , .
г :
, , . , ( ). while. :
while(<>)
}
< >
}
, . , . do-while. :
do
}
< >
}
while(<>)
, .
, , . for, ( ), , . for, , . :
for (i=0; i<10; i++)
{
< >
}
:
i=0
while(i<10)
}
< >
i++;
}
, - :
:
#include<math.h>
#include<stdio.h>
#include<conio.h>
int main()
{
float x, y;
for(x=4; x<=9; x++)
{
y=pow(2,x);
printf("%d ",y);
}
getch();
return 0;
}
1 , . .
2.1
ij | ij | ij | ||||||
1. , .
2. г .
3. ѳ.
|
|
4. .
3
.
, , ( ). ົ .
, . , , , . . , . , , break.
. 0, - 1. , 2 .. 1 2.
: , . . , .
, . , .
1 10. - :
:
#include <conio.h>
#include <stdio.h>
int main()
{
clrscr();
int i, j;
for (i = 1; i <= 10; i++)
{
for (j = 1; j <= 10; j++)
printf("%4d", i * j);
printf("\n");
}
return 0;
}
ε [a;b], . f(x) , , . 3.1.
3.1
y = f(x) | . | ij [a;b] | "" h | ||
2+ x - x2 | 0,5 | [0;1,0] | 0,15 | 10-5 | |
(1-x)4 | ̳ 1,0 | [0,2;1,5] | 0,25 | 0,5*10-4 | |
cosx+chx | ̳ 0,0 | [-0,8;0,4] | 0,25 | 10-5 | |
x1/3*(1-x)2/3 | 0,33 | [0,1;0,6] | 0,1 | 10-5 | |
x 3-6x2+9x+4 | 1,0 | [0,2;1,5] | 0,3 | 10-5 | |
x 3-6x2+9x+4 | ̳ 3,0 | [2;4] | 0,3 | 0,5*10-5 | |
2*x2-x4 | ̳ 0,0 | [-2;0,8] | 0,15 | 10-4 | |
(x2-3x+2)/ (x2+2x-1) | ̳ 1,4 | [1;2] | 0,15 | 0,5*10-4 | |
x*(x-1)x/3 | ̳ 0,75 | [0,1;1,2] | 0,2 | 10-5 | |
x*e-x | 1,0 | [0,1;1,5] | 0,25 | 10-5 | |
ln2x/x | 7,389 | [6;8] | 0,15 | 10-5 | |
x+1/x | ̳ 1,0 | [0,1;1,5] | 0,2 | 10-4 | |
arctgx-ln(1+x2)/2 | 1,0 | [0,15;1,5] | 0,2 | 10-5 | |
│x│*e-│x-1│ | -1,0 | [-2;-0,5] | 0,15 | 10-5 | |
ln2x/x | ̳ 1,0 | [0,1;1,9] | 0,2 | 10-4 |
1. .
2. ?
3. [a;b]?
4. , .
4
, , .
. ϳ ѳ , '. ' , . ѳ .
|
|
:
<' > [];
ѳ . . , '.
ѳ . , 0. int a[100] , 100 [0] [99]. , ' :
. = < > * <. >.
ѳ '.
ѳ . [100] , 100 , [200], , [200] , 2 . - , :
unsigned arr[40], long double al[1000], char ch[80].
, . ѳ . : , . .
:
1) . , , ;
2) . ϳ
, .
:
1) , , .
< > < > [ N]...[ 1] = {< >};
, 10 :
int array [10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
b 10 int b [10] = {1, 2, 3, 4}, 1, 2, 3 4. 0, , , .
, , ;
2) , . .
< > < > [ ][ N1]...[ 1] =
{< >};
, int array [ ] = {1, 2, 3, 4};
, .
, . ,
char c[ ] = {"ABCD"};
ABCD. , . . :
char c [ ] = {'A', 'B', 'C', 'D', '\0'};
, , , . ֳ .
. , [ ].
ѳ , , . ,
int a[9]; a[0] = 0; a[1] = 0; a[2] = 0; a[3] = 0; a[4] = 0; a[5] = 0; a[6] = 0; a[7] = 0; a[8] = 0;
a.
. , [ ], . - , , (*), - . i- array array[i] *(array+i).
int a[5], 5 : a[0], a[1], a[2], a[3], a[4]. - . pa int *pa;, pa = &a[0]; pa a[0]. pa+1 , pa+i i- , a[i], *(pa+i) i- . , pa = &a[0]; pa = a;, i- a[i] *(+i). - . . , , . pa = a; pa++; . = pa; ++; , .
, , , , . . 5.1, 1000.
* | *(pa+1) | *(pa+2) | *(pa+3) | *(pa+4) |
a[0] | a[1] | a[2] | a[3] | a[4] |
* | *(+1) | *(+2) | *(+3) | *(+4) |
5.1.
+ 3 + 3 1000 + 3*sizeof(int) = 1000 + 3*2 = 1006. , , *(+3) *(+3). .
[10].
:
#include <stdio.h>
int main()
{
int N = 10;
int p = 0;
int A[N] = {5, -3, 0, 3, 9, -2, 0, 2, 1, 4};
for (int i = 0; i < N; i++)
if (A[i] == 0) p++;
printf("%d", p);
return 0;
}
. . , . ij . .
4.1
ij | |||
(10) | 0 ≤ X[i] ≤ 4 | ||
(15) | A[i] > 0 | ||
X(12) | Y | -2 ≤ X[i] ≤ 2 | |
B(14) | B[i] >0 | ||
(10) | C[i] <0 | ||
D(17) | D . | ||
Y(12) | Y[i] >0 | ||
Z(13) | R 䒺 Z. | ||
N(15) | N, . | ||
X(10) | X[i]>0 | ||
A(12) | A[i]> 0 | ||
X(14) | Y . | X[i] >0 | |
X(16) | Y Z 䒺 . | ||
B(12) | . | B[i]< 0 | |
(16) | . | -2 ≤ C[i] ≤ 2 |
1. , .
2. ?
3. ?
4. ?
5. .
5
, , .
ѳ . , . , , . . :
< > < > [ N]...[ 2] [ 1];
, . , , .
. , int d [2][3] = {{1, 2, 3},{4, 5, 6}};
, , , :
int f [2][2] = {{1, 2}, {3, 4}}; int f [2][2] = {1, 2, 3, 4};
, , . ,
int array [ ] [3] = {0, 1, 2, 3, 4, 5}; : 0, 1, 2; 3, 4, 5. , , :
int array [ ][3] = {{0}, {3, 4}};
m [0][0] 0, m [1][0] 3, m [1][1] 4.
0 | 1 | 2 | 3 | |
0 | [0][0] | [0][1] | [0][2] | [0][3] |
1 | [1][0] | [1][1] | [1][2] | [1][3] |
2 | [2][0] | [2][1] | [2][2] | [2][3] |
6.1.
1010. - :
:
#include <stdio.h>
#include <conio.h>
int main()
{
clrscr();
int A[10][10], i, j;
for (i = 0; i < 10; i++)
{
for (j = 0; j < 10; j++)
{
A[i][j] = (i + 1) * (j + 1);
printf("%4d", A[i][j]);
}
printf("\n");
}
Return 0;
}
, . . .
5.1
' | ij | ||
A(10;15) | . . | aij>0 | |
A(N;M) | . . | N≤20 M≤15 | |
B(N;M) | , . | N≤12 | |
V(15;10) | . | ||
C(N;N) | , . | cij>0 N≤12 | |
D(K;K) | 䒺 , . | K≤10 | |
D(10;10) | 䒺 , . . | ||
F(N;M) | , . | N≤20 M≤15 | |
F(10;10) | . . | ||
N(10;10) | 5, . | nij/5*5=nij | |
N(10;10) | N (10,), , N. . | ||
P(N;N) | , . | N≤15 | |
R(K;N) | , . | N≤20 M≤10 | |
S(25;8) | 24 7 . 8- , 25- . | ||
T(N;M) | . . | N≤20 M≤15 |
1. .
2. .
3. ?
4. ?
5. N*M ?
6
, .
ϳ , , . . , .
: . .
, , . , , .
,
int func1(int x)
{
x=x+1;
return x;
}
, , 䳿, . , , void , . ,
void func2(int &x)
{
x=x+1;
}
, . . - :
:
#include <conio.h>
#include <stdio.h>
Int fact(int n)
{
int i, r = 1;
for (i = 1; i <= n; i++)
r *= i;
Return r;
}
Int main()
{
Clrscr();
int a = 4;
printf("%d", fact(a));
Return 0;
}
, . . - :
:
#include <stdio.h>
void Fill(int *M, int n)
{
Int i;
for (i = 0; i <= n; i++)
M[i] = rand() % 10;
}
Int main()
{
int A[10], B[20];
Fill(A, 10);
Fill(B, 20);
Return 0;
}
. 6.1. .
6.1
, | ||
ϳ , r ; X(15), Y(15) | ³ | |
, | ||
ϳ , r (2, 2); X(17), Y(17) | ³ | |
, , , -- ᒺ | ||
X(12), Y(15), Z(17) | ||
A(10), B(15), C(20) | ||
ϳ X(10, 15) i Y(20, 12), | ||
(10, 12) (15, 10) | ||
, -- X1(14), X2(16) | ||
A(N, N) i B(M, M) | ||
, -- X(14); -- 䒺 Y(16) | , | |
ϳ A(N, M) i B(M, N) | ||
(15, 15) (20, 20) | ||
䒺 X(24), Y(17), Z(13) |
1. .
2. , , .
3. , .
4. ` .
5. , .
6. , .
7
, ; , ; .
ѳ. () - , ("). ³ char. :
, :
char word[5];
word[5]=line;
, :
char str[]=line;
:
char str[5]={'l', 'i', 'n', 'e', '\0'}; \0 .
(\0) . ʳ , . , , , '. ("), (\). - , \.
, , string.h. , . :
strcat(line1, line2) - ' ;
strcpy(line1, line2) - s2 s1;
strlen(line) - ( ).
. - :
:
#include<string.h>
#include<stdio.h>
int main()
{
char line[]="agrg";
printf("%d",strlen(line));
getch();
return 0;
}
, . 8.1. . .
7.1
, , . | |
, , . | |
³ , , . | |
, (, , , ) . | |
, . , . | |
. , . | |
, . | |
³ , . | |
. | |
, ( , |