int main()
{
int i,a,b,c;
Char result [32];
Printf ("Please enter two plastic data to be calculated: \ n");
While(scanf("%d%d ",& i, & b) = = 2)
{
I = 0;
c = a & ampb;
The result of printf ("operation is:% d &;; %d = %d\n ",a,b,c);
Printf ("The binary representation of the operation result is:");
If (c==0)
{
printf(" 0 \ n ");
}
other
{
And (c)
{
Result [I] = c% 2+48;
i++;
c = c/2;
}
for(I = I- 1; I & gt=0; I-)// Output binary strings in reverse order.
{
printf("%c ",result[I]);
}
printf(" \ n ");
}
}
Returns 0;
}
Test results:
Please enter two pieces of plastic data to be calculated:
1 2
The calculation result is:1&; 2 = 0
The binary representation of the operation result is: 0.
2 3
The calculation results are: 2&; 3 = 2
The binary representation of the operation result is: 10.
3 4
The calculation results are: 3&; 4 = 0
The binary representation of the operation result is: 0.
15 8
The calculation result is:15&; 8 = 8
The binary representation of the operation result is: 1000.
15 7
The calculation result is:15&; 7 = 7
The binary representation of the operation result is: 1 1 1.
15 9
The calculation result is:15&; 9 = 9
The binary representation of the operation result is: 100 1.