Документ взят из кэша поисковой машины. Адрес оригинального документа : http://ofvp.phys.msu.ru/science_education/lections/CS/cp/S2_1.pdf
Дата изменения: Sat Sep 17 13:28:40 2011
Дата индексирования: Mon Oct 1 21:09:14 2012
Кодировка:
2 (1 , )
1 ( ):
#include main(){printf("\n = %f", 3.1415*3.0*3.0);}

#include double area (double); void main() { (, , ...); } double area (double f) { ; }

. - , ():
01011101 10100010 01011101 10100010

, ?
9310 = 93 = 3·100 + 9·101

- ,

010111012 = 1·20 +0·21 + 1·22 +1·23 +1·24 + 0·25 + 1·26 + 0·27 = 9310

, = 11111111 = 28-1 = 25510. 0 В 255. . - : -2: 210 = 0000 00102: : 1111 1101: +1 : 1111 1110. : -128 В 127. . Visual C++ (short) 2 ( -215 В 215-1 0 В 216-1 6553510 (unsigned short), (long) 4 ( -231 В 231-1). , : 0.13·108. float , - . : 23 , 8 . , , ! => , , .


2 (1 , ) , VC int short long char float double 138 -367 1,345 -0,15 4 2 4 1 4 8 138 -367 1.345 -0.15 -.15 138L , 8 16 118 = 9
10 10

2

, short<=int<=long + unsigned: unsigned int, unsigned short, unsigned long, unsigned char



sizeof() . , sizeof(int).

: 011 0x11 178.e-3
5

1116 = 17

: 178 10
-3

0,367 10

0.367e5

char: 'A' , '\64', 'b', : '\07' - . ( ):
int a; float b; int c,d,e; // int g = 5; //

. float f ; double df = 1.0; f = df; /*(), (warning) */ f = (float) df; /* */
·


int i; i = 10;

=

" "
i=j=k=l=10;



l=10; k=10; j=10; i=10;

·

+
i = 2+5; i = i+1; printf("%d", 4+20);


2 (1 , )
· · · · ·

3
i = 5-2; x = 2.4*j; x = 4.0/3.0;

* /
i = -j;

.
float x; int i =1, j =2; x = i/j; => 0.0 (!) ( ) => 0.5 x = (float)i/j;

% i = 10%7;

3 ( 7)

·

: -, *, /, % -> +, :
i = (j+1)*(j+2)

" "
·

:
i = i + 1; i = i -1; i++; i--;

(i++) (++i), :
main() { int a = 1, b = 1, ap, pb; ap = a++; pb = ++b; printf("%d %d %d %d", a, ap, b,pb); }

-> 2

1

2

2

·

:
i+=5; i*=10; -=, /=, %= -> i = i + 5; -> i = i*10;

%d %6d %f % %g %6f %6.2f %ld %lf %o %x % %s %% , 6 dddd.dddd d.dddd e ddd %f, % , 6 double () .
char c; c = '\64' printf("%c",c); -> 4 printf("%d",c); -> 52 printf("%o",c); -> 64


2 (1 , )

4

:
\n \t \ \" \\

"" : #include double pow(double, double); double double double double double double double sin(double); cos(double); tan(double); sqrt(double); exp(double); log(double); log10(double); : : x = y3,12 x = sin(y) -> -> x = pow(y, 3.12); x = sin(y);

- - - - - :

double fabs(double); int abs(int); double cosh(double);

double sinh(double);

double tanh(double);

ex + e 2 x -x e -e - : sinh( x) = 2 x e - e-x - : tanh( x) = x e + e-x cosh( x) =

-x

double atan2(double, double); - , ~ sin, - cos.


int rand(void) /* 0 RAND_MAX */ void srand(unsigned int); /* */ .
#include #include int i,j; srand( (unsigned)time( NULL )); i = rand(); j = rand();

. , . . . §1.1, 1.2, 2.1 ­ 2.5, 2.7, 2.8, 2.10, 7.2