【单选题】【消耗次数:1】
若有以下定义:structnode{intdata;structnode*next;}structnode*p;已建立如下图所示的链表:┌──┬──┐┌──┬──┐┌──┬──┐p→│data│next┼→│data│next┼→...→│data│NULL│└──┴──┘└──┴──┘└──┴──┘指针p指向第一个结点,能输出链表所有结点的数据成员data的循环语句是()。
while(p!=NULL){printf("%d,",p-p++;}
while(p){printf("%d,",p.data);p=p-}
for(;p!=NULL;p++)printf("%d,",p
-for(;p;p=p-next)printf("%d,",(*p).data);
参考答案:
复制
纠错
相关题目
【单选题】 若按如下定义,函数link的功能是()。其中head指向链表首结点,整个链表结构如下图:┌──┬─┐┌──┬─┐┌──┬──┐head→│data│┼→│data│┼→…→│data│NULL│└──┴─┘└──┴─┘└──┴──┘structnode{intdata;structnode*next;};voidlink(structnode*head){structnode*p=head;while(p!=NULL){if(p-data%2==1)printf("%d",p-p=p-}}
①  计算链表head中结点的个数
②  遍历链表head,输出表中值为奇数的元素
③  删除链表head中的所有结点
④  插入一个新元素到链表head中
【单选题】 若有定义:structnode{intdata;structnode*next;};已建立如下图所示的链表:┌─┬─┐┌─┬─┐┌─┬─┐head→│2│┼→│4│┼→…→│28│┼→NULL└─┴─┘└─┴─┘└─┴─┘指针head指向链表首结点,以下函数的功能是()。voidfun(structnode*head){structnode*p=head;while(1){p=p-printf("%d",p-data);if(!p)break;}}
①  显示单向链表中第一个结点的数据
②  显示单向链表中最后一个结点的数据
③  显示单向链表中的所有数据
④  显示单向链表中除第一个结点外的所有数据
【单选题】 若有以下定义:structnode{intdata;structnode*next;}*p,*q;已建立如下图所示的链表:┌──┬──┐┌──┬──┐...p→│data│next┼→│data│NULL│└──┴──┘└──┴──┘┌──┬──┐q→│data│next│└──┴──┘不能将指针q所指结点连到上图所示链表末尾的语句是()。
①  q-next=NULL;p=p-p-next=q;
②  p=p-p-next=q;q-next=NULL;
③  p=p-q-next=p-p-next=q;
④  q-next=p-p=p-p-next=q;
【单选题】 若有以下定义:structnode{intdata;structnode*next;}structnodem,n,k,*head,*p;已建立如下图所示的链表:mnk┌──┬──┐┌──┬──┐┌──┬──┐head→│data│next┼→│data│NULL│p→│data│next│└──┴──┘└──┴──┘└──┴──┘指针head指向变量m,m.next指向变量n,p指向变量k,不能把结点k插到m和n之间形成新链表的程序段是()。
①  p-next=head-m.next=p;
②  (*head).next=p;(*p).next=
③  head-next=p-next=head
④  -m.next=k.next=
【单选题】 假定一个链表的表头指针为f,结点结构为(data,next),则向该链表的表头插入一个由p所指向的结点时,应执行的操作为p->next=f和( )。
①  p=f->next
②  f=p->next
③  f=p
④  f->next=p
【单选题】 假定一个链表的表头指针为f,结点结构为(data,next),则向该链表的表头插入一个由p所指向的结点时,应执行的操作为p-next=f和( )。
①  p=f-next
②  f=p-next
③  f=p
④  f-next=p
【单选题】 在一个链队中,假设f和r分别为队头和队尾指针,p指向一个已生成的结点,现要为该结点的数据域赋值e,并使结点入队的运算为p-data=e; p-next=NULL ; 和( )。
①  A . f-next=p; f=p;
②  B. r-next=p;r=p;
③  C. p-next=r;r=p;
④  D. p-next=f;f=p;
【判断题】 在双向链表中,要删除p所指的结点,其中所用的一条语句(p-prior)-next=p-next;的功能是:使P所指结点的直接前驱的右指针指向P所指结点的直接后继。
①  正确
②  错误
【单选题】 以下程序运行的输出结果是。main(){ int p=30;printf(%d\n,(p/320?p/10:p%3)); }
①  0
②  1
③  2
④  3
【单选题】 下述程序的运行结果( )。 #includevoid main() { int p,a=0; if(p=a!=0)printf(%d\n else printf(%d\n,p+2); }
①  1
②  2
③  3
④  5
随机题目
【判断题】 Mary will win the prize.玛丽会赢得比赛。So she will. 是的,她会。以上句子对应的中文意思是否准确。
①  正确
②  错误
【单选题】 Anewtechnique______,theyieldsasawholeincreasedby20percent.
①  working out
②  having worked out
③  having been worked out
④  to have been worked out
【单选题】 The manager promised to keep me _____ of how our business was going on.
①  to be informed
②  on informing
③  informed
④  informing
【单选题】 The match was canceled because most of the members______a match without a standard court.
①  objected to having
②  were objected to have
③  objected to have
④  were objected to having
【单选题】 In Australia,_____ the Asians make their influence in businesses large and small.
①  feeling
②  feel
③  felt
④  to be felt
【单选题】 The teacher doesnt permit______in class.
①  smoke
②  to smoke
③  smoking
④  to have a smoke
【单选题】 Thechildrenwenttheretowatchtheirontower________.
①  to erect
②  erecting
③  be erected
④  being erected
【单选题】 Mr. Johnson preferred_______ heavier work to do.
①  to be given
②  to be giving
③  to have given
④  having given
【单选题】 The speaker, _______ for her splendid speeches, was warmly received by the audience.
①  having known
②  being known
③  knowing
④  known
【单选题】 I remember _______ to help us if we ever got into trouble.
①  once offering
②  him once offering
③  him to offer
④  to offer him