.


:




:

































 

 

 

 


3

: ('+'), ('-'), ('*') ('/'). . .

('/') . , . , . , x , y . :

x = 7 / 3; x = 2
y = 7 / 3; y = 2.000000
y = 7.0 / 3; y = 2.333333
y = (double)7 / 3; y = 2.333333

. , , . , 7/3 2. 2 2.000000 y.

. .

1.1.1. a b.
(a + b)/2 . . . , : res = (a + b)/2.0. :

#include < stdio.h >

int a=3,b=7;

double res;

void main(void)

{

x = 6 % 3 x = 0
x = 8 % 3 x = 2
x = -6 % 3 x = 0
x = -8 % 3 x = -2

/*scanf("%d %d",&a,&b);*/

res = (a + b) / 2.0;

printf("%lf\n",res);

}

i = i + 1 i++
i = i - 1 i--
i = i + a i += a
i = i %a1 i %= a

'%'. ( n 0 n 1 ).

. , i = i + 1 i ++. < op > , i = i < op > a i < op >= a. :

1.1.2. h: m, h , m . , h 1: m 1 , h 2: m 2 (0 ≤ h 1, h 2 ≤ 23, 0 ≤ m 1, m 2 ≤ 59). , (hres: mres) . , 24 .

h 1: m 1 h 2: m 2, , . , h 1: m 1 = 23:50 h 2: m 2 = 13:20, 13 30 .

h: m h *60 + m , . , time 1 = h 1 * 60 + m 1 , time 2 = h 2 * 60 + m 2 . timeRes = (time 2 time 1 + 24 * 60) % (24 * 60) . timeRes .

#include < stdio.h >

int h1, h2, m1, m2, time1, time2, timeRes, hres, mres;

void main(void)

{

h1 = 23; m1 = 50; h2 = 13; m2 = 20;

time1 = h1 * 60 + m1; time2 = h2 * 60 + m2;

timeRes = (time2 - time1 + 24 * 60) % (24 * 60);

hres = timeRes / 60; mres = timeRes % 60;

printf("%d:%d\n",hres,mres);

}

1.1.1. , m . n ?
1.1.2. . , n , m ?

1.1.3. n . a, b, c , n.

1.1.1. , (m + n 1) / n.
1.1.2. , m / n.

 

'' ('and'), '' ('or'), '' ('not') 2 ('xor'). :

x and y x && y
x or y x || y
not x ! x
x xor y x ^ y

:

x y X and y   x y x or y   x not x   x y x xor y
                           
                           
                           
                           

, . (x == y) !(x xor y). " 2", x xor y = (x + y) mod 2. -:

not (x and y) = (not x) or (not y)

!(x && y) =! x ||! y

1.2.1. :

1. : x = y;
2. : x imp y = (not x) or y

. ( , ). .

, . , , , . . , .



<== | ==>
. | 2.
:


: 2016-03-28; !; : 353 |


:

:

, .
==> ...

1334 - | 1257 -


© 2015-2024 lektsii.org - -

: 0.013 .