C++程序设计教程参考答案第6章科学出版社.pdfVIP

  • 0
  • 0
  • 约5.93千字
  • 约 6页
  • 2020-04-27 发布于安徽
  • 举报

C++程序设计教程参考答案第6章科学出版社.pdf

习题 1 结点数据之和: #includeiostream.h struct Node{ int data; Node *next; }; int sum(Node* head) { int s=0; while(head){ s+=head-data; if(head-next)couthead-data-; else couthead-dataendl; head=head-next; } return s; } void main() { Node node[10],*h=node; for(int i=0;i10;i++){// 建立链表 node[i].data=i+1; if(i==9)node[i].next=0; else node[i].next=node[i+1]; } cout 链表为: ; int s=sum

文档评论(0)

1亿VIP精品文档

相关文档