.


:




:

































 

 

 

 





() . , ( ++ 1 16 ). , (, , ), .. . , .. &, . . - . , . "" , , .

:

struct { _ _: _; _ _: _;

} _;

_ - int, unsigned int ( unsigned), signed int ( signed), char, short, long . ( ANSI int.)

. 7.3

 

_ - , ; - - , , .

, .. . ++ ++ - 0 16. :

struct { int : 10; int b:14; } , *;

 

, :

_._

__->_

__._

(* __)._

, :

. = 1; = &; ->b = 48;

I. , . , , , () (. 7.3). , IBM PC, , , . . 7.3.

, . ++. -, . ( ) (' , .

. 7.4.

int a: 10 int :14 6 , . - (. 7.4).

, . , D ( 68):

union { char simb;

struct { int x:5; int y:3;) hh; } cod;

cod.hh.x = 4; cod.hh.y = 2; cout cod.simb; // 'D'

 

. 7.5 68, 'D'.

. 7.5

:

//7-05. - , , tinclude <iostream.h>

// // 16 - : unsigned char cod(int a,int b) { union { unsigned char z;

struct { unsigned int x:4; // unsigned int y:4; // } hh; } un;

un.hh.x = a % 16; un.hh.y = b % 16; return un.z;

)

//

// -:

void binar(unsigned char ch){

union { unsigned char ss;

struct { unsigned aO:l;

unsigned al:1;

unsigned a2:1;

unsigned a3:1;

unsigned a4:1;

unsigned a5:l;

unsigned :1;

unsigned a7:1;

} byte;

} cod;

cod.ss = ch; // // : cout "\nHOMEPA : 76543210"; cout " :";

cout "\t" cod.byte.a7 " " cod.byte.; cout " " cod.byte.a5 " " cod.byte.a4; cout " " cod.byte.a3 " " cod.byte.a2; cout " " cod.byte.al " " cod.byte.aO; cout "\n";

*

void main() {

int k;

int , n;

cout "\nm = "; cin m;

cout "n = "; cin n;

k - cod(m,n);

cout "cod = " k;

binar(k);

}

:

m = I <Enter>

n = 3 <Enter>

cod = 49

: 76543210

: 00110001

:

m = 0 <Enter>

n = I <Enter>

cod =16

: 76543210

: 00010000

. cod() binar() , . cod() hh, un, un, . binary() - , "" byte, cod.

++ - , . .

 





:


: 2018-10-15; !; : 215 |


:

:

, , .
==> ...

1784 - | 1465 -


© 2015-2024 lektsii.org - -

: 0.01 .