题3.58
long decode2(long x, long y, long z) {
long result = 0;
x = x * (y - z);
result = ((x << 63) >> 63) ^ x;
return result;
}
题3.60
long loop(long x, int n) {
long result = 0;
long mask;
for (mask = 1; mask != 0; mask <<= n) {
result |= (x & mask);
}
return result;
}
题3.68
题3.70
// A. 0; 8; 0; 8
// B. 16字节
// C. 代码如下:
union ele {
struct {
long* p;
long y;
}e1;
struct {
long x;
union ele* next;
}e2;
};
void proc(union ele* up) {
up->e2.x = *(up->e2.next->e1.p) - up->e2.next->e1.y;
}
题3.71
#include <stdio.h>
#define BUFSIZE 64
void good_echo() {
char buf[BUFSIZE];
int i;
while (1) {
if (!fgets(buf, BUFSIZE, stdin)) return;
for (i = 0; buf[i] && buf[i] != '\n'; i++)
if (putchar(buf[i]) == EOF) return;
if (buf[i] == '\n') {
putchar('\n');
return;
}
}
}
int main() {
good_echo();
return 0;
}