【单选题】【消耗次数: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
随机题目
【简答题】 输入一个字符,如果是大写字母,则把其变成小写字母;如果是小写字母,则变成大写字母;其它字符不变。请在补充完整缺省的内容。main( ) { char scanf(“%c”, if (A=ch chZ) [填空1]; else if([填空2]) ch=ch-32;printf(”%c\n”,ch); }
【简答题】 以下程序的运行结果是[填空1]。#include stdio.hvoid main(){int i,j;for (i=4;ii--){printf(*for (j=1;jj++)printf(*printf(\n}}
【简答题】 有以下程序#includestdio.hmain(){ int x;scanf(%d,if(x15) printf(%d,x-5);if(x10) printf(%dif(x5) printf(%d\n,x+5); }若程序运行时从键盘输入12回车,则输出结果为[填空1]。
【简答题】 有以下程序#includestdio.hmain(){ int x;scanf(%d,if(x15) printf(%d,x-5);if(x10) printf(%dif(x5) printf(%d\n,x+5); }若程序运行时从键盘输入7回车,则输出结果为[填空1]。
【单选题】 有以下程序#includestdio.hmain(){ int a=1,b=0;if(--a) else if(a==0) b+=2;else b+=3;printf(“%d\n”,b); }程序运行后的输出结果是(  )。
①  0
②  1
③  2
④  3
【单选题】 有以下程序#includestdio.hmain(){ int a=1,b=0;if(--a) else if(a==0) b+=2;else b+=3;printf(“%d\n”,b); }程序运行后的输出结果是。
①  0
②  1
③  2
④  3
【单选题】 假定所有变量均已正确说明,下列程序段运行后x的值是。a=b=c=0;x=35;if(!a) x=-1;else if(b);if(c) else
①  35
②  34
③  4
④  3
【单选题】 以下程序的输出结果是(  )。#include stdio.h void main( ){ int a,b;for(a=1,b=1;aa++){ if (b=10) break;if (b%5==1) { b+=5; continue; } }printf(%d\n }
①  101
②  6
③  4
④  3
【单选题】 下列条件语句中输出结果与其他语句不同的是。
①  if(a==0)printf(“%d\n”,y);else printf(“%d\n”,x);
②  if(a)printf(“%d\n”,x); else printf(“%d\n”,y);
③  if(a==0)printf(“%d\n”,x);else printf(“%d\n”,y);
④  if(a!=0)printf(“%d\n”,x);elseprintf(“%d\n”,y);
【单选题】 写出下面程序的执行结果。main(){ int x=1,y=1,z=0;if(z0)if(y0) x=3;else x=5;printf(%d\tif(z=y0) x=3;else if(y= =0 ) x=5;else x=7;printf(%d\tprintf(%d\t}
①  1 5 1
②  1 7 0
③  3 7 0
④  5 5 0