7. 丐亠仆舒仆亶 仂仗亠舒仂
7
int main()
{
unsigned char a, b, min, max;
a = 100; b = 200;
min = (a < b) ? a : b;
max = (a > b) ? a : b;
printf("Result: min = %d, max = %d", min, max);
return 0;
}
Result: min = 100, max = 200
8. 仂亞亳亠从亳亠 亳 弍亳仂于亠 仂仗亠舒亳亳
8
Result: ????
int main()
{
unsigned char a, b, r1, r2, r3, r4;
a = 0xF0; b = 0x0F;
r1 = a & b;
r2 = a && b;
r3 = a | b;
r4 = a || b;
printf("Result: r1 = %x, r2 = %xn", r1, r2);
printf("Result: r3 = %x, r4 = %x", r3, r4);
return 0;
}
9. 仂亞亳亠从亳亠 亳 弍亳仂于亠 仂仗亠舒亳亳
9
Result: r1 = 0, r2 = 1
Result: r3 = ff, r4 = 1
int main()
{
unsigned char a, b, r1, r2, r3, r4;
a = 0xF0; b = 0x0F;
r1 = a & b;
r2 = a && b;
r3 = a | b;
r4 = a || b;
printf("Result: r1 = %x, r2 = %xn", r1, r2);
printf("Result: r3 = %x, r4 = %x", r3, r4);
return 0;
}
10. 亳仂于舒 舒亳仄亠亳从舒
10
Result: ????
int main()
{
unsigned char a, r1, r2;
a = 41;
r1 = a << 2;
r2 = a >> 2;
printf("Result: r1 = %dn", r1);
printf("Result: r2 = %d", r2);
return 0;
}