#include<stdio.h>
typedef union{
unsigned char data;
struct{
unsigned char bit1 :1;
unsigned char bit2 :1;
unsigned char bit3 :1;
unsigned char bit4 :1;
unsigned char bit5 :1;
unsigned char bit6 :1;
unsigned char bit7 :1;
unsigned char bit8 :1;
}BIT;
}DATA;
DATA input(void)
{
unsigned char hako[9];
DATA d;
int i;
while (1) {
for (i = 0; i < 8; i++) {
hako[i] -= '0';
if (1 < hako[i]) {
break;
}
}
if (i == 8) {
d.BIT.bit8 = hako[0];
d.BIT.bit7 = hako[1];
d.BIT.bit6 = hako[2];
d.BIT.bit5 = hako[3];
d.BIT.bit4 = hako[4];
d.BIT.bit3 = hako[5];
d.BIT.bit2 = hako[6];
d.BIT.bit1 = hako[7];
break;
}
}
return d;
}
void output(char* str, DATA d)
{
printf("%s\t%u%u%u%u%u%u%u%u\n", str
, d.BIT.bit8, d.BIT.bit7, d.BIT.bit6, d.BIT.bit5,
d.BIT.bit4, d.BIT.bit3, d.BIT.bit2, d.BIT.bit1);
}
int main(void){
DATA a,b,sum,sub,AND,OR,aNOT,bNOT,XOR;
int i;
a = input();
b = input();
sum.data = a.data + b.data;
sub.data = a.data - b.data;
AND.data = a.data & b.data;
OR.data = a.data | b.data;
aNOT.data = ~a.data;
bNOT.data = ~b.data;
XOR.data = a.data ^ b.data;
output("和", sum);
output("差", sub);
output("AND", AND);
output("OR", OR);
output("ANOT", aNOT);
output("BNOT", bNOT);
output("XOR", XOR);
return 0 ;
}
I2luY2x1ZGU8c3RkaW8uaD4KCnR5cGVkZWYgdW5pb257CiAgdW5zaWduZWQgY2hhciBkYXRhOwogIHN0cnVjdHsKICAgIHVuc2lnbmVkIGNoYXIgYml0MSA6MTsKICAgIHVuc2lnbmVkIGNoYXIgYml0MiA6MTsKICAgIHVuc2lnbmVkIGNoYXIgYml0MyA6MTsKICAgIHVuc2lnbmVkIGNoYXIgYml0NCA6MTsKICAgIHVuc2lnbmVkIGNoYXIgYml0NSA6MTsKICAgIHVuc2lnbmVkIGNoYX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