单选题:以下程序的输出结果是()。
以下程序的输出结果是()。
struct NODE{ int num; struct NODE * next;};
int main(void)
{ struct NODE *p, *q, *r;
p=(struct NODE *)malloc(sizeof(struct NODE));
q=(struct NODE *)malloc(sizeof(struct NODE));
r=(struct NODE *)malloc(sizeof(struct NODE));
p->num = 10; q->num=20; r->num = 30;
p->next =q; q->next = r;
printf(“%d\n”, p->num+q->next->num);
return 0; }
A.10
B.20
C.30
D.40
答案:D
struct NODE{ int num; struct NODE * next;};
int main(void)
{ struct NODE *p, *q, *r;
p=(struct NODE *)malloc(sizeof(struct NODE));
q=(struct NODE *)malloc(sizeof(struct NODE));
r=(struct NODE *)malloc(sizeof(struct NODE));
p->num = 10; q->num=20; r->num = 30;
p->next =q; q->next = r;
printf(“%d\n”, p->num+q->next->num);
return 0; }
A.10
B.20
C.30
D.40
答案:D