有以下程序
#include
struct NODE
{int num; struct NODE *next; }
main()
{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
",p->num+q->next->num);
}
程序运行后的输出结果是( )
#include
struct NODE
{int num; struct NODE *next; }
main()
{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
",p->num+q->next->num);
}
程序运行后的输出结果是( )
举一反三
- 中国大学MOOC: 下面程序执行后的输出结果是:#include <iostream>#include <cmath>using namespace std;struct NODE {int num; struct NODE *next;};int main(){struct NODE *p,*q,*r;p=new NODE;q=new NODE;r=new NODE;p->num=10; q->num=20; r->num=30;p->next=q;q->next=r;cout<<p->num+q->next->num<<endl; return 0;}
- 以下程序运行后的输出结果是 ________ struct NODE { int num; struct NODE *next; } main() { struct NODE s[3], *p, *q, *r; int sum=0; s[0].num=1; s[1].num=2; s[2].num=3; s[0].next=s+1; s[1].next=s+2; s[2].next=s; p=s; q=p->next; r=q->next; sum+=q->next->num; sum+=r->next->next->num; printf("%d", sum); }
- 设有以下定义: struct node { int data; struct node *next; }*p; 则以下的语句中正确的是()。 A: p=malloc(sizeof(struct node)) B: p=(struct node *)malloc(sizeof(struct node)) C: *p=(struct node *)malloc(4) D: p=(struct node )malloc(sizeof(struct node))
- 中国大学MOOC: 对于如下语句struct node{ int id; struct node *next;}*p;p=(struct node*)malloc(sizeof(struct node)*10);如下说法正确的是
- 已有定义如下:struct node{ int data;struct node *next;} *p;以下语句调用malloc函数填空。使指针p指向一个具有struct node类型的动态存储空间。p = (struct node *)malloc(【 】);