正在加载图片...
第一部分c语言程序设计上机指导 printf("\nd",p→x) printf("\n暑d",(++p)→x) printf("\n d",++(*(++ p)-y) 错误所在 错误 5.该 delete函数实现将链表中的指定数值的结点删除掉,找出其中的错误语句。 struct list *delete(head struct list *head int key; void free( struct list p,g; while(p!=NULL&&p->datal=key) g-p p=p>next if(p==NULL) return(NULL)i if(p=shead eseq→next=p free (p)i return(head) 正确 错误 错误所在 应改为 #include <stdio. h> struct sI [char*sl nt 1 struct s *sI s1a[]={{"abcd",1,a+1},{"efgh”,2,a+2},{"ijk1”,3,a}第一部分 C 语言程序设计上机指导 ·91· ·91· void main( ) {p= a; printf("\n %d", p→x); printf("\n %d",(++ p)→x); printf("\n %d",*(++ p)→y); printf("\n %d",++(*(++ p)→y)); } 正确 运行结果: 错误所在: 错误 应改为: 5. 该 delete 函数实现将链表中的指定数值的结点删除掉,找出其中的错误语句。 struct list *delete(head,key) struct list *head; int key; { void free( ); struct list p,q; p=head; while(p!=NULL&&p->data!=key) { q=p; p=p->next; } } if(p==NULL) return(NULL); if(p==head) h=head→next; else q→next=p→next; free(p); return(head); } 正确 运行结果: 错误所在: 错误 应改为: 6. #include <stdio.h> struct s1 {char *s1; int i; struct s1 *s1p; }; main( ) { s1 a[ ]={{“abcd”,1,a+1},{“efgh”,2,a+2},{“ijkl”,3,a} };
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有