垃圾代码评析——关于《C程序设计伴侣》9.4——链表(一)

【样本】

1. #include <stdio.h>2. #include <stdlib.h>3. #include <stdbool.h>4. #include <string.h>5. . typedef struct _student8. {9. char name[20];10. float score;. struct _student* next;13. }student;14. 15. void printlist(student*);16. 17. int main( )18. {. student* head = NULL ;21. student* tail = NULL ;22.23. char name[20] = “” ;24. float score = 0.0f ;25.26. bool ishead = true;,name,&score)!=EOF)28. {..student* node = malloc(sizeof(student)); 32..strcpy(node->name,name);35.node->score = score;36…if(ishead)40.{.head = node ;.head->next = NULL ;.tail = node;47..ishead = false;50.}51.else52.{.tail->next = node;.tail = node;57.}. . .. if(NULL!=tail)64.tail->next = NULL;65. else66.return -1;67..70. printlist(head);71. return 0;72. }73. 74. void printlist(student* head)75. {. student* node = head;. while(NULL!=node)80. {.printf(,node->name,node->score);.node = node->next;85. }86. },美国空间,香港服务器,香港服务器莫找借口失败,只找理由成功。

垃圾代码评析——关于《C程序设计伴侣》9.4——链表(一)

相关文章:

你感兴趣的文章:

标签云: